我想通过编码的UI测试构建器自动化网站,例如,打开Chrome,然后打开Facebook,输入用户名和密码,然后登录。
我创建了以下步骤:
public void openchrome()
{
// Launch '%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe'
ApplicationUnderTest chromeApplication = ApplicationUnderTest.Launch(this.openchromeParams.ExePath, this.openchromeParams.AlternateExePath);
}
/// <summary>
/// openfb - Use 'openfbParams' to pass parameters into this method.
/// </summary>
public void openfb()
{
#region Variable Declarations
WinClient uINewTabClient = this.UINewTabGoogleChromeWindow.UINewTabButton.UINewTabClient;
WinEdit uIAddressandsearchbarEdit = this.UINewTabGoogleChromeWindow.UIItemGroup.UIAddressandsearchbarEdit;
WinWindow uIFacebookLogInorSignUWindow = this.UIFacebookLogInorSignUWindow;
#endregion
// Click 'New Tab' client
Mouse.Click(uINewTabClient, new Point(44, 6));
// Type 'https://www.facebook.com' in 'Address and search bar' text box
uIAddressandsearchbarEdit.Text = this.openfbParams.UIAddressandsearchbarEditText;
// Click 'Facebook - Log In or Sign Up - Google Chrome' window
Mouse.Click(uIFacebookLogInorSignUWindow, new Point(535, 85));
}
/// <summary>
/// username - Use 'usernameParams' to pass parameters into this method.
/// </summary>
public void username()
{
#region Variable Declarations
WinWindow uIFacebookLogInorSignUWindow = this.UIFacebookLogInorSignUWindow;
WinMenu uIAutofillMenu = this.UIItemWindow.UIItemClient.UIAutofillMenu;
WinControl uIFacebookLogInorSignUDocument = this.UINewTabGoogleChromeWindow.UIFacebookLogInorSignUDocument;
#endregion
// Click 'Facebook - Log In or Sign Up - Google Chrome' window
Mouse.Click(uIFacebookLogInorSignUWindow, new Point(1275, 167));
// Type '{NumPad1}' in 'Autofill' popup menu
Keyboard.SendKeys(uIAutofillMenu, this.usernameParams.UIAutofillMenuSendKeys, ModifierKeys.None);
// Type '{NumPad4}{NumPad3}{NumPad5}{NumPad4}{NumPad5}{NumPad9}b' in 'Facebook - Log In or Sign Up - Google Chrome' document
Keyboard.SendKeys(uIFacebookLogInorSignUDocument, this.usernameParams.UIFacebookLogInorSignUDocumentSendKeys, ModifierKeys.None);
}
/// <summary>
/// password - Use 'passwordParams' to pass parameters into this method.
/// </summary>
public void password()
{
#region Variable Declarations
WinWindow uIFacebookLogInorSignUWindow = this.UIFacebookLogInorSignUWindow;
WinMenu uIAutofillMenu = this.UIItemWindow.UIItemClient.UIAutofillMenu;
#endregion
// Click 'Facebook - Log In or Sign Up - Google Chrome' window
Mouse.Click(uIFacebookLogInorSignUWindow, new Point(1476, 177));
// Type '{NumPad1}{NumPad2}{NumPad3}' in 'Autofill' popup menu
Keyboard.SendKeys(uIAutofillMenu, this.passwordParams.UIAutofillMenuSendKeys, ModifierKeys.None);
}
/// <summary>
/// login
/// </summary>
public void login()
{
#region Variable Declarations
WinWindow uIFacebookLogInorSignUWindow = this.UIFacebookLogInorSignUWindow;
#endregion
// Click 'Facebook - Log In or Sign Up - Google Chrome' window
Mouse.Click(uIFacebookLogInorSignUWindow, new Point(1647, 177));
}
但是当我创建任何网站自动化时,我在Coded UI测试构建器创建它时出现此错误:
CodedUITestMethod1 TestProject3测试方法失败TestProject3.CodedUITest1.CodedUITestMethod1抛出异常: ...
Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToLaunchApplicationException:&#34;无法启动应用程序。这可能是由于以下原因之一:您没有足够的权限使用此应用程序。&#34;文件: %PROGRAMFILES(x86)的%\谷歌\铬\应用\的chrome.exe。
这也是
另一个控件是阻止控件。请阻止 控制可见并重试操作。
答案 0 :(得分:0)
如果您可以使用有助于归档目的的评论的新信息来编辑您的帖子。
&#34; FailedToPerformActionOnBlockedControlException&#34;是因为在您尝试单击的控件前面有另一个控件,或者它位于与其看起来不同的逻辑位置。
尝试通过执行以下操作来点击控件作为一个点:
Mouse.Click(control.ToPoint());
其中ToPoint是一个扩展方法,它接受一个控件,然后获取control.BoundingRectangle的x和y坐标。