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

南笙酒味 提交于 2019-11-29 08:21:45
Charles Cartwright

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

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

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.

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