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

后端 未结 3 421
南笙
南笙 2021-01-06 11:00

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

3条回答
  •  孤城傲影
    2021-01-06 11:16

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

    // .Net Core workaround #1: Slow Firefox webdriver
    string 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\\AppData\Local\Mozilla\Firefox\Profiles
    // Without this, if your AUT uses SSO, you will always get prompted for the PIN or Two factor authentication
    FirefoxProfile 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-1252
    CodePagesEncodingProvider.Instance.GetEncoding(437);
    Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
    
    _driver = new FirefoxDriver(geckoService, ffOptions);
    

提交回复
热议问题