Selenium geckodriver executes findElement 10 times slower than chromedriver (.Net)

喜欢而已 提交于 2019-12-23 02:58:11

问题


Sorry didn't find a similar question and maybe somebody can help.

Due to additional requirements we have to test our project not only with Chrome but with Firefox as well. When we simply changed a test context to Firefox it turned out that all calls of findElement took 10 times more time than with Chrome. All tests are completely ruined. We tried to use different test machines but the results are the same. The project is on Core .Net. For testing we use MSTest V2, Firefox 63 (64 bit) and Geckodriver 0.22 (64 bit) .

Very appreciate any help.


回答1:


Yep. You’re definitely hitting the performance issue that is part of .NET Core. It doesn’t happen on Chrome, IE, or Edge, because the driver executables for each of those browsers (unlike geckodriver) listen on both the IPv4 and IPv6 loopback addresses. If you were to specify “::1” as the host for geckodriver with .NET, the problem would disappear.

Refer to https://github.com/SeleniumHQ/selenium/issues/6597




回答2:


By referring to the previous answer, my issue was solved by below code.

string geckoDriverDirectory = "Path of geckodriver.exe"
FirefoxDriverService geckoService = 
FirefoxDriverService.CreateDefaultService(geckoDriverDirectory);
geckoService.Host = "::1";
var firefoxOptions = new FirefoxOptions();
firefoxOptions.AcceptInsecureCertificates = true;
Driver = new FirefoxDriver(geckoService, firefoxOptions);


来源:https://stackoverflow.com/questions/53629542/selenium-geckodriver-executes-findelement-10-times-slower-than-chromedriver-ne

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!