如何在 Mozilla Firefox 36.0.4 的 CodedUI 测试中启动 URL
How to Launch URL in CodedUI testing in Mozilla Firefox 36.0.4
我正在 CodedUI 测试中测试 gmail 登录页面并完成记录所有操作。
现在我想首先启动 google 页面的登录页面,我已经实现了如下所示的代码。
BrowserWindow.CurrentBrowser = "IE";
this.UIMap.UIAdminloginMozillaFirWindow.LaunchUrl(new Uri("https://www.google.com"));
但是错误是:
添加 Selenium 以便在 Firefox 中进行测试。
[TestClass]
public class UnitTest1
{
FirefoxDriver firefox;
// This is the test to be carried out.
[TestMethod]
public void TestMethod1()
{
firefox = new FirefoxDriver();
firefox.Navigate().GoToUrl("http://www.google.com/");
IWebElement element = firefox.FindElement(By.Id("lst-ib"));
element.SendKeys("Google\n");
}
// This closes the driver down after the test has finished.
[TestCleanup]
public void TearDown()
{
firefox.Quit();
}
}
您可以使用 Selenium 组件进行编码 UI 跨浏览器测试 (https://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d),一组将编码 UI 调用转换为 WebDriver 调用的扩展,从而启用支持对于 Firefox 和 Chrome.
下载安装程序并运行。如果您使用测试记录器构建测试,请照常使用 Internet Explorer 进行记录(记录在 Firefox 或 Chrome 中不起作用)。在您的代码中,在调用 BrowserWindow.Launch("url")
之前,将浏览器类型设置如下:
BrowserWindow.CurrentBrowser = "Firefox"; // or "Chrome" or "IE"
使用 HtmlControl
及其后代的几乎所有常规属性和方法。我从经验中知道访问 HtmlControl.ControlDefinition
会抛出 NotSupportedException,并且 Mouse.StartDragging()/StopDragging()
也不起作用。调试有时也很有趣。
我正在 CodedUI 测试中测试 gmail 登录页面并完成记录所有操作。
现在我想首先启动 google 页面的登录页面,我已经实现了如下所示的代码。
BrowserWindow.CurrentBrowser = "IE";
this.UIMap.UIAdminloginMozillaFirWindow.LaunchUrl(new Uri("https://www.google.com"));
但是错误是:
添加 Selenium 以便在 Firefox 中进行测试。
[TestClass]
public class UnitTest1
{
FirefoxDriver firefox;
// This is the test to be carried out.
[TestMethod]
public void TestMethod1()
{
firefox = new FirefoxDriver();
firefox.Navigate().GoToUrl("http://www.google.com/");
IWebElement element = firefox.FindElement(By.Id("lst-ib"));
element.SendKeys("Google\n");
}
// This closes the driver down after the test has finished.
[TestCleanup]
public void TearDown()
{
firefox.Quit();
}
}
您可以使用 Selenium 组件进行编码 UI 跨浏览器测试 (https://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d),一组将编码 UI 调用转换为 WebDriver 调用的扩展,从而启用支持对于 Firefox 和 Chrome.
下载安装程序并运行。如果您使用测试记录器构建测试,请照常使用 Internet Explorer 进行记录(记录在 Firefox 或 Chrome 中不起作用)。在您的代码中,在调用 BrowserWindow.Launch("url")
之前,将浏览器类型设置如下:
BrowserWindow.CurrentBrowser = "Firefox"; // or "Chrome" or "IE"
使用 HtmlControl
及其后代的几乎所有常规属性和方法。我从经验中知道访问 HtmlControl.ControlDefinition
会抛出 NotSupportedException,并且 Mouse.StartDragging()/StopDragging()
也不起作用。调试有时也很有趣。