c# Selenium 2.53 moving to marionette driver after firefox upgrade to 47

怎甘沉沦 提交于 2019-11-28 01:41:50

问题


I am trying to move into the upgraded firefox web browser automation using selenium. It seems that selenium needs marionette driver to continue working. I followed the instructions set by the devs,

  1. downloaded the driver
  2. renamed it to wires.exe

The following code didnt manage to properly set the PATH to a custom path.

System.Environment.SetEnvironmentVariable("webdriver.gecko.driver", "@C:\DOWNLOADS\wires.exe")

so i added wires.exe to the debug\bin folder and then wires.exe worked properly but i got the following error

System.InvalidOperationException was caught Message=entity not found Source=WebDriver

this is the code i use to start webdriver

FirefoxOptions option1 = new FirefoxOptions();
option1.IsMarionette = true;
option1.AddAdditionalCapability("marionette", true);
driver = new FirefoxDriver(option1);

回答1:


I too got the "Entity Not Found" error using FirefoxDriver(new FirefoxOptions()). It appears to be looking for firefox.exe in C:\Program Files (x86)\Nightly and not finding it. I found this working :

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
IWebDriver driver = new FirefoxDriver(service);



回答2:


I try with this and it's working:

  1. Install FirefoxDevEdition
  2. Download geckodriver.exe

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\Users\jmalpartida\Downloads\geckodriver-v0.8.0-win32", "geckodriver.exe");
service.Port = 64444;
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Firefox Developer Edition\firefox.exe";
IWebDriver driver = new FirefoxDriver(service);



回答3:


First of all, you need to add the driver to your system path, not as an env variable. Second, you need to set the flag in a desired capability, not a Firefox option. See: Marionette Webdriver

As such for remote webdriver:

DesiredCapabilities capabilities = DesiredCapabilities.Firefox();  
capabilities.SetCapability("marionette", true); 
var driver = new RemoteWebDriver(capabilities); 

To add the webdriver to your windows path:

The easiest way is to open the start menu > search for environment > open edit the system environment variables > click on environment variables > search in the list for Path > click on edit > add ;C:\path\to\webdriver\location\wires.exe to the end and click save.

For your local (non-webdriver) tests you are right, you can run your webdriver using the following:

var driver = new FirefoxDriver(new FirefoxOptions());

You should not have to use

option1.IsMarionette = true; option1.AddAdditionalCapability("marionette", true);

If you have set the driver path correctly in your path environment variable.



来源:https://stackoverflow.com/questions/37761080/c-sharp-selenium-2-53-moving-to-marionette-driver-after-firefox-upgrade-to-47

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