Firefox Webdriver 非常慢
Firefox Webdriver is extremely slow
我们使用 selenium webdriver dll 设置 运行 我的自动化套件。我只在 Firefox 中 运行nning 测试时遇到了这个问题。在 Firefox 中的测试 运行 非常慢,加载页面需要 3-4 分钟,但是,当我 运行 在同一台机器上手动使用 Firefox 浏览器进行相同的测试时,我没有遇到这种缓慢的情况。有时 运行 在 Firefox 上自动化时,我们也会得到 "Connection was reset" 页面。此外,相同的测试 运行 在 Chrome 和 IE 中正常。
我们使用以下环境:
Firefox 版本 28、37(代理设置为使用系统设置)
网络驱动程序 (dll) 版本 2.45
Windows 7
之前我们曾在 Windows XP 中使用 Firefox 版本 14,16 和 Webdriver 版本 2.37 运行 进行相同的设置,但我们没有遇到此问题。
我们使用以下代码调用 Firefox :
Proxy proxy = new Proxy();
proxy.Kind = ProxyKind.System;
FirefoxProfile profile = new FirefoxProfile();
profile.SetProxyPreferences(proxy);
RemoteWebDriver dr = new FirefoxDriver(new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"), profile, TimeSpan.FromSeconds(120));
dr.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
dr.Manage().Window.Maximize();
dr.Manage().Cookies.DeleteAllCookies();
dr.Navigate().GoToUrl(WebSiteUrl);
剩余测试步骤......
请有人帮我解决这个问题。
提前致谢。
现在可能对你没有任何好处,但我在 Firefox 45 和 Webdriver 2.15 上遇到了同样的问题。原来问题是隐式等待设置。就我而言,我有:
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
这一行执行需要 190 秒(是的,超过 3 分钟!)。删除它可以将启动时间缩短到 8 秒以下!
这就是我解决“极慢的 FirefoxDriver”问题的方法:
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
service.Host = "::1";
IWebDriver driver = new FirefoxDriver(service);
以上代码强制 geckodriver
使用 IPv6 协议,该协议在与 UI 元素交互时工作速度快很多倍。
我们使用 selenium webdriver dll 设置 运行 我的自动化套件。我只在 Firefox 中 运行nning 测试时遇到了这个问题。在 Firefox 中的测试 运行 非常慢,加载页面需要 3-4 分钟,但是,当我 运行 在同一台机器上手动使用 Firefox 浏览器进行相同的测试时,我没有遇到这种缓慢的情况。有时 运行 在 Firefox 上自动化时,我们也会得到 "Connection was reset" 页面。此外,相同的测试 运行 在 Chrome 和 IE 中正常。
我们使用以下环境:
Firefox 版本 28、37(代理设置为使用系统设置)
网络驱动程序 (dll) 版本 2.45
Windows 7
之前我们曾在 Windows XP 中使用 Firefox 版本 14,16 和 Webdriver 版本 2.37 运行 进行相同的设置,但我们没有遇到此问题。
我们使用以下代码调用 Firefox :
Proxy proxy = new Proxy();
proxy.Kind = ProxyKind.System;
FirefoxProfile profile = new FirefoxProfile();
profile.SetProxyPreferences(proxy);
RemoteWebDriver dr = new FirefoxDriver(new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"), profile, TimeSpan.FromSeconds(120));
dr.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
dr.Manage().Window.Maximize();
dr.Manage().Cookies.DeleteAllCookies();
dr.Navigate().GoToUrl(WebSiteUrl);
剩余测试步骤......
请有人帮我解决这个问题。
提前致谢。
现在可能对你没有任何好处,但我在 Firefox 45 和 Webdriver 2.15 上遇到了同样的问题。原来问题是隐式等待设置。就我而言,我有:
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
这一行执行需要 190 秒(是的,超过 3 分钟!)。删除它可以将启动时间缩短到 8 秒以下!
这就是我解决“极慢的 FirefoxDriver”问题的方法:
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
service.Host = "::1";
IWebDriver driver = new FirefoxDriver(service);
以上代码强制 geckodriver
使用 IPv6 协议,该协议在与 UI 元素交互时工作速度快很多倍。