How to use the gecko executable with Selenium

前端 未结 10 1413
滥情空心
滥情空心 2020-11-28 08:20

I\'m using Firefox 47.0 with Selenium 2.53. Recently they have been a bug between Selenium and Firefox which make code not working. One of the solution is to use the Marion

相关标签:
10条回答
  • 2020-11-28 09:11

    You need to specify the system property with the path the .exe when starting the Selenium server node. See also the accepted anwser to Selenium grid with Chrome driver (WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property)

    0 讨论(0)
  • 2020-11-28 09:13

    I'm using FirefoxOptions class to set the binary location with Firefox 52.0, GeckoDriver v0.15.0 and Selenium 3.3.1 as mentioned in this article - http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/

    The java code that I used -

    FirefoxOptions options = new FirefoxOptions();
    options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //location of FF exe
    
    FirefoxDriver driver = new FirefoxDriver(options);
    driver.get("http://www.google.com");
    
    0 讨论(0)
  • 2020-11-28 09:14

    The solutions above work fine for local testing and firing up browsers from the java code.If you fancy firing up your selenium grid later then this parameter is a must have in order to tell the remote node where to find the geckodriver:

    -Dwebdriver.gecko.driver="C:\geckodriver\geckodriver.exe"
    

    The node cannot find the gecko driver when specified in the Automation Java code.

    So the complete command for the node whould be (assuming node and hub for test purposes live on same machine) :

    java -Dwebdriver.gecko.driver="C:\geckodriver\geckodriver.exe" -jar selenium-server-standalone-2.53.0.jar -role node -hub http://localhost:4444/grid/register
    

    And you should expect to see in the node log :

    00:35:44.383 INFO - Launching a Selenium Grid node
    Setting system property webdriver.gecko.driver to C:\geckodriver\geckodriver.exe
    
    0 讨论(0)
  • 2020-11-28 09:15

    This can be due to system cannot find firefox installed location on path.

    Try following code, which should work.

    System.setProperty("webdriver.firefox.bin","C:\\Program Files\\Mozilla Firefox\\firefox.exe"); 
    System.setProperty("webdriver.gecko.driver","<location of geckodriver>\\geckodriver.exe");
    
    0 讨论(0)
提交回复
热议问题