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

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


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);


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


A complete .Net Core webdriver for Firefox 7/14/2020:

// .Net Core workaround #1: Slow Firefox webdriverstring projectFolder = Directory.GetParent(Directory.GetCurrentDirectory()).FullName;string geckoDriverDirectory = projectFolder + "\\netcoreapp3.1\\";FirefoxDriverService geckoService = FirefoxDriverService.CreateDefaultService(geckoDriverDirectory);geckoService.Host = "::1";var ffOptions = new FirefoxOptions();ffOptions.BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\Firefox.exe"; ffOptions.AcceptInsecureCertificates = true;// This profile will by-pass *ALL* credentials. Note that Chrome uses Internet Explorer settings, so it does not need this.// You must pre-setup the profile, by launching Firefox and doing phone authentication// The profile's location is: C:\Users\<windows logon>\AppData\Local\Mozilla\Firefox\Profiles// Without this, if your AUT uses SSO, you will always get prompted for the PIN or Two factor authenticationFirefoxProfile profile = new FirefoxProfileManager().GetProfile("Selenium");ffOptions.Profile = profile;// DotNet Core workaround #2- Code page// https://stackoverflow.com/questions/56802715/firefoxwebdriver-no-data-is-available-for-encoding-437// https://stackoverflow.com/questions/50858209/system-notsupportedexception-no-data-is-available-for-encoding-1252CodePagesEncodingProvider.Instance.GetEncoding(437);Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);_driver = new FirefoxDriver(geckoService, ffOptions);