Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA

前端 未结 14 1118
眼角桃花
眼角桃花 2020-12-25 13:10

I am not able to run my script in any of the browsers. Below is the error i get for firefox. The location where firefox is installed is correct. Dont know what is wrong.

相关标签:
14条回答
  • 2020-12-25 13:49

    Try this:

    System.setProperty("webdriver.gecko.driver", "geckodriver p");
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette", true);
    driver = new FirefoxDriver(capabilities);
    
    0 讨论(0)
  • 2020-12-25 13:49
    File pathBinary = new File("Firefox.exe location");
    FirefoxBinary ffBinary = new FirefoxBinary(pathBinary);
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    FirefoxDriver driver = new FirefoxDriver(ffBinary,firefoxProfile);
    

    You need to add binary of the browser

    or

    Best and forever solution: Just add Firefox.exe location to environmental variables

    0 讨论(0)
  • 2020-12-25 13:52

    I was also facing the same problem and I spent more than a week to fix it. Restarting my machine seemed to have fixed it, but only temporarily.

    There was a solution to increase the maximum number of ephemeral ports by editing the registry file. That seemed to have fixed the problem but that also, only temporarily.

    For sometime, I kept thinking if I was trying to access a driver which is no longer available, so I have tried to call:

    driver.quit()
    

    And then recreate the browser instance, which only gave me: SessionNotFoundException.

    I now realized that I had used BOTH System.setProperty as well as ffCapability.setCapability to set the path of the binary.

    I then tried with only System.setProperty => No luck there.

    Only ffCapability.setCapability => Voila!!! So far it has been working fine. Hopefully it will work great when I try to re-run my scripts tomorrow and the day after and the day after... :)

    Bottomline: Use only this

    ffCapability.setCapability("binary", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //for windows`
    

    Hope it helps!

    0 讨论(0)
  • 2020-12-25 13:53

    be attention, if path to browser have space (as example "...\Program Files (x86)...") you need add double quotes to value of param.

    Example:

    -Dwebdriver.firefox.bin="D:\Program Files (x86)\Mozilla Firefox\firefox.exe"
    

    All has been run successfully when added double quotes.

    0 讨论(0)
  • 2020-12-25 13:55

    For me it was just a matter of changing the path variable to: 'C:\Program Files\Mozilla Firefox' instead of 'C:\Program Files (x86)\Mozilla Firefox'

    0 讨论(0)
  • 2020-12-25 13:58

    This code simply worked for me

    System.setProperty("webdriver.firefox.bin", "C:\\Program Files\\Mozilla Firefox 54\\firefox.exe");
    String Firefoxdriverpath = "C:\\Users\\Hp\\Downloads\\geckodriver-v0.18.0-win64\\geckodriver.exe";
    System.setProperty("webdriver.gecko.driver", Firefoxdriverpath);
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette", true);
    driver = new FirefoxDriver(capabilities);
    
    0 讨论(0)
提交回复
热议问题