【问题标题】:How to Launch URL in CodedUI testing in Mozilla Firefox 36.0.4如何在 Mozilla Firefox 36.0.4 的 CodedUI 测试中启动 URL
【发布时间】:2015-03-30 07:02:15
【问题描述】:

我正在 CodedUI 测试中测试 gmail 登录页面并完成记录所有操作。

现在我想首先启动谷歌页面的登录页面,我已经实现了如下所示的代码。

BrowserWindow.CurrentBrowser = "IE";
this.UIMap.UIAdminloginMozillaFirWindow.LaunchUrl(new Uri("https://www.google.com"));

但错误是:

【问题讨论】:

  • 我看到表示错误的波浪线,但错误是什么?当您将鼠标悬停在 LaunchUrl 方法上时,Visual Studio 会告诉您什么?
  • 查看我之前使用 selenium 的 answer

标签: c# .net coded-ui-tests visual-studio-2010


【解决方案1】:

您可以将 Selenium 组件用于 Coded UI 跨浏览器测试 (https://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d),这是一组将 Coded 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() 也不起作用。调试有时也很有趣。

【讨论】:

    【解决方案2】:

    添加 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();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多