Web アプリケーション用に次の Web コード化された UI テストを作成しました。
実行すると、テスト ケースは正常に動作します。
テスト ケースが「負荷テスト」の一部として追加されると、エラー メッセージのスローが開始されます。
Test Error TestError 4 Test method testWithSQLExp.CodedUITest2.CodedUITestMethod1 threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
ところで、ユーザー数が 1 に設定されている場合、同じ codedUI テストを使用した同じ負荷テストはうまく機能します。
私のコードは次のとおり です UIMap.cs
public void AssertMethod1()
{
#region Variable Declarations
HtmlCell uIItem1363758Cell = this.UIFirstNetHomePageWindWindow.UIEConnectFirstMeritBaDocument1.UIMainContent_gvAccounTable.UIItem1363758Cell;
#endregion
// Verify that the 'InnerText' property of '$13,637.58' cell equals '$13,637.58'
Assert.AreEqual(this.AssertMethod1ExpectedValues.UIItem1363758CellInnerText, uIItem1363758Cell.InnerText);
}
public void RecordedMethod1()
{
#region Variable Declarations
HtmlEdit uICompanyEdit = this.UIFirstNetHomePageWindWindow.UIBusinessDocument.UICompanyEdit;
HtmlEdit uIUsernameEdit = this.UIFirstNetHomePageWindWindow.UIBusinessDocument.UIUsernameEdit;
HtmlEdit uITxtPasswordEdit = this.UIFirstNetHomePageWindWindow.UIEConnectFirstMeritBaDocument.UITxtPasswordEdit;
#endregion
// Go to web page 'https://dev.firstmerit.com/business/index.html' using new browser instance
this.UIFirstNetHomePageWindWindow.LaunchUrl(new System.Uri(this.RecordedMethod1Params.UIFirstNetHomePageWindWindowUrl));
// Type 'demo' in 'Company' text box
uICompanyEdit.Text = this.RecordedMethod1Params.UICompanyEditText;
// Type '{Tab}' in 'Company' text box
Keyboard.SendKeys(uICompanyEdit, this.RecordedMethod1Params.UICompanyEditSendKeys, ModifierKeys.None);
// Type 'user' in 'Username' text box
uIUsernameEdit.Text = this.RecordedMethod1Params.UIUsernameEditText;
// Type '{Enter}' in 'Username' text box
Keyboard.SendKeys(uIUsernameEdit, this.RecordedMethod1Params.UIUsernameEditSendKeys, ModifierKeys.None);
// Type '********' in 'txtPassword' text box
uITxtPasswordEdit.Password = this.RecordedMethod1Params.UITxtPasswordEditPassword;
// Type '{Enter}' in 'txtPassword' text box
Keyboard.SendKeys(uITxtPasswordEdit, this.RecordedMethod1Params.UITxtPasswordEditSendKeys, ModifierKeys.None);
}
CodedUITest2.cs
名前空間 testWithSQLExp {
[CodedUITest]
public class CodedUITest2
{
public CodedUITest2()
{
}
[TestMethod]
public void CodedUITestMethod1()
{
// To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
// For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
this.UIMap.RecordedMethod1();
this.UIMap.AssertMethod1();
}
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
private TestContext testContextInstance;
public UIMap UIMap
{
get
{
if ((this.map == null))
{
this.map = new UIMap();
}
return this.map;
}
}
private UIMap map;
}
}