如何使用 C# 提交请求中的字符串以获得茄子性能
How to submit a string in a Request using C# for Eggplant Performance
2022 年的问候。
我目前正在使用 C# 评估名为 Eggplant performance 的性能工具。
我正在测试的应用程序有一个用户设置密码,要求我插入密码中的某些随机字符。
示例:
密码=密码1
然后应用程序会让我随机插入3个字符的密码。
每个必填字段都有一个长度在 7-9 个字符之间的 ID,但总是长于 6 且短于 10。
传输的有效负载如下所示:
B806b8220=s&e210cdd9=s&cd5d5105=d&landingpage=快递等
我已经能够完成关联这些字段的工作并获得相关逻辑。
我正在努力解决的问题是,因为我没有开发背景,所以我正在提交这个问题。
相关的累积值如下所示:
Passphrase is set as string
我需要提交的地方是:
Submit the Request
我到处都收到一堆错误。
任何正确方法的指导将不胜感激。
(使用 Visual Studio 2015)
////附加信息:
提取发生的代码。我提取了 9 个 ID(因为密码 1 是 9 个字符)。
然后我说如果提取的ID大于6,就用那个加上相关的密码片。这有效 100%
ExtractionCursor extractionCursor41 = new ExtractionCursor();
if (response41.Find(extractionCursor41, "Enter only the required characters of", ActionType.ACT_EXIT_VU, true, SearchFlags.SEARCH_IN_BODY))
{
Set("c_surephraseIDs_41", response41.ExtractList(extractionCursor41, "name=\"", "\" id=\"", "viLabel=\"Password 9\" />", true, 9, ActionType.ACT_EXIT_VU, SearchFlags.SEARCH_IN_BODY));
}
if (extractionCursor41.Succeeded)
{
WriteMessage("Items extracted to list variable: c_surephraseIDs_41...");
List<string> valuesList = Get<List<string>>("c_surephraseIDs_41");
foreach (string listItem in valuesList)
{
WriteMessage(String.Format("Item: {0}", listItem));
}
List<string> Array2 = Get<List<string>>("c_surephraseIDs_41");
List<string> Array1 = new List<string> { "p", "a", "s", "s", "w", "o", "r", "d", "1" };
List<string> Array3 = new List<string> { "", "", "", "", "", "", "", "", "" };
int j = 0;
for (int i = 0; i < 9; i++)
{
if (Array2[i].Length > 6)
{
Array3[j] = Array2[i] + "=" + Array1[i];
WriteMessage(Array3[j]);
j++;
}
}
string Passphrase = Array3[0] + "&" + Array3[1] + "&" + Array3[2];
}
// Rule: Verify that the result code matches what was recorded
response41.VerifyResult(HttpStatus.OK, ActionType.ACT_WARNING);
}
然后在解析回网站的请求中:
using (Request request44 = WebBrowser.CreateRequest(HttpMethod.POST, url44, 44))
{
request44.SetReferer(new Url(protocol1, onlinebankinguat3, "/absa-online/login.jsp"));
request44.SetHeader("Origin", "https://onlinebankinguat3.absa.co.za");
request44.SetHeader("Content-Type", "application/x-www-form-urlencoded");
Form postData44 = new Form();
postData44.CharEncoding = Encoding.GetEncoding("ISO-8859-1");
//The below 3 are originally as per the recording.
//postData44.AddElement(new InputElement("B3391b84d", "a", Encoding.GetEncoding("ISO-8859-1")));
//postData44.AddElement(new InputElement("B54824db9", "r", Encoding.GetEncoding("ISO-8859-1")));
//postData44.AddElement(new InputElement("fa2ebc87", "d", Encoding.GetEncoding("ISO-8859-1")));
//The below is the one I am trying to send over the wire
postData44.AddElement(new InputElement("",GetString("Passphrase"), Encoding.GetEncoding("ISO-8859-1")));
//
postData44.AddElement(new InputElement("landingpage", "express", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("dsp", "false", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("dspid", "0", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("dspreferer", "null", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("goto", "", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("", "", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("", "", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("nonce", "0", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("uniq", GetMillisecondsSinceEpoch(-5) /* Replaced timestamp 1641064306006 (2022-01-01T21:11:46.006000+02:00) */ , Encoding.GetEncoding("ISO-8859-1")));
request44.SetMessageBody(postData44);
在构建字符串 Passphrase 时,我可以看到它工作正常:
The string builds correctly
关于发送请求,这是响应:
The errors that is logged once I try send the request
我这样做了:
for (int i = 0; i < 9; i++)
{
if (Array2[i].Length > 6)
{
Array3[j] = Array2[i] + "=" + Array1[i];
if (j == 0)
{
Set<string>("PPleft1", Array2[i]);
Set<string>("PPright1", Array1[i]);
}
if (j == 1)
{
Set<string>("PPleft2", Array2[i]);
Set<string>("PPright2", Array1[i]);
}
if (j == 2)
{
Set<string>("PPleft3", Array2[i]);
Set<string>("PPright3", Array1[i]);
}
}
}
2022 年的问候。
我目前正在使用 C# 评估名为 Eggplant performance 的性能工具。
我正在测试的应用程序有一个用户设置密码,要求我插入密码中的某些随机字符。
示例: 密码=密码1 然后应用程序会让我随机插入3个字符的密码。
每个必填字段都有一个长度在 7-9 个字符之间的 ID,但总是长于 6 且短于 10。
传输的有效负载如下所示:
B806b8220=s&e210cdd9=s&cd5d5105=d&landingpage=快递等
我已经能够完成关联这些字段的工作并获得相关逻辑。
我正在努力解决的问题是,因为我没有开发背景,所以我正在提交这个问题。
相关的累积值如下所示:
Passphrase is set as string
我需要提交的地方是:
Submit the Request
我到处都收到一堆错误。
任何正确方法的指导将不胜感激。 (使用 Visual Studio 2015)
////附加信息:
提取发生的代码。我提取了 9 个 ID(因为密码 1 是 9 个字符)。
然后我说如果提取的ID大于6,就用那个加上相关的密码片。这有效 100%
ExtractionCursor extractionCursor41 = new ExtractionCursor();
if (response41.Find(extractionCursor41, "Enter only the required characters of", ActionType.ACT_EXIT_VU, true, SearchFlags.SEARCH_IN_BODY))
{
Set("c_surephraseIDs_41", response41.ExtractList(extractionCursor41, "name=\"", "\" id=\"", "viLabel=\"Password 9\" />", true, 9, ActionType.ACT_EXIT_VU, SearchFlags.SEARCH_IN_BODY));
}
if (extractionCursor41.Succeeded)
{
WriteMessage("Items extracted to list variable: c_surephraseIDs_41...");
List<string> valuesList = Get<List<string>>("c_surephraseIDs_41");
foreach (string listItem in valuesList)
{
WriteMessage(String.Format("Item: {0}", listItem));
}
List<string> Array2 = Get<List<string>>("c_surephraseIDs_41");
List<string> Array1 = new List<string> { "p", "a", "s", "s", "w", "o", "r", "d", "1" };
List<string> Array3 = new List<string> { "", "", "", "", "", "", "", "", "" };
int j = 0;
for (int i = 0; i < 9; i++)
{
if (Array2[i].Length > 6)
{
Array3[j] = Array2[i] + "=" + Array1[i];
WriteMessage(Array3[j]);
j++;
}
}
string Passphrase = Array3[0] + "&" + Array3[1] + "&" + Array3[2];
}
// Rule: Verify that the result code matches what was recorded
response41.VerifyResult(HttpStatus.OK, ActionType.ACT_WARNING);
}
然后在解析回网站的请求中:
using (Request request44 = WebBrowser.CreateRequest(HttpMethod.POST, url44, 44))
{
request44.SetReferer(new Url(protocol1, onlinebankinguat3, "/absa-online/login.jsp"));
request44.SetHeader("Origin", "https://onlinebankinguat3.absa.co.za");
request44.SetHeader("Content-Type", "application/x-www-form-urlencoded");
Form postData44 = new Form();
postData44.CharEncoding = Encoding.GetEncoding("ISO-8859-1");
//The below 3 are originally as per the recording.
//postData44.AddElement(new InputElement("B3391b84d", "a", Encoding.GetEncoding("ISO-8859-1")));
//postData44.AddElement(new InputElement("B54824db9", "r", Encoding.GetEncoding("ISO-8859-1")));
//postData44.AddElement(new InputElement("fa2ebc87", "d", Encoding.GetEncoding("ISO-8859-1")));
//The below is the one I am trying to send over the wire
postData44.AddElement(new InputElement("",GetString("Passphrase"), Encoding.GetEncoding("ISO-8859-1")));
//
postData44.AddElement(new InputElement("landingpage", "express", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("dsp", "false", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("dspid", "0", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("dspreferer", "null", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("goto", "", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("", "", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("", "", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("nonce", "0", Encoding.GetEncoding("ISO-8859-1")));
postData44.AddElement(new InputElement("uniq", GetMillisecondsSinceEpoch(-5) /* Replaced timestamp 1641064306006 (2022-01-01T21:11:46.006000+02:00) */ , Encoding.GetEncoding("ISO-8859-1")));
request44.SetMessageBody(postData44);
在构建字符串 Passphrase 时,我可以看到它工作正常:
The string builds correctly
关于发送请求,这是响应:
The errors that is logged once I try send the request
我这样做了:
for (int i = 0; i < 9; i++)
{
if (Array2[i].Length > 6)
{
Array3[j] = Array2[i] + "=" + Array1[i];
if (j == 0)
{
Set<string>("PPleft1", Array2[i]);
Set<string>("PPright1", Array1[i]);
}
if (j == 1)
{
Set<string>("PPleft2", Array2[i]);
Set<string>("PPright2", Array1[i]);
}
if (j == 2)
{
Set<string>("PPleft3", Array2[i]);
Set<string>("PPright3", Array1[i]);
}
}
}