亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

運行后出現這樣的提示,怎么解決

Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA

Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

System info: host: 'LU', ip: '192.168.219.1', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'

Driver info: driver.version: FirefoxDriver

at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:75)

at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)

at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)

at openliu.main(openliu.java:9)


正在回答

1 回答

看這個報錯應該是firefox安裝路徑不是默認路徑。

  解決方法:方法1、最簡單的重新安裝firefox到默認路徑。哈哈

  方法2、直接用System.setPropert方法設置webdriver.firefox.bin的值,如

  System.setProperty("webdriver.firefox.bin","D:\\Program Files\\Mozilla Firefox\\firefox.exe");

  方法3、 用FirefoxBinary類和public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile)這個構造方法,直接上代碼

  File pathToFirefoxBinary = new File("D:\\Program Files\\Mozilla Firefox\\firefox.exe"); FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary); WebDriver driver = new FirefoxDriver(firefoxbin,null);//這里使用這個構造方法。

  應該還可以在環境變量里面設置firefox的路徑也可以,有興趣的可以試一下。

  注:有人可能會不知道webdriver.firefox.bin,可以看一下源碼,其中

  org.openqa.selenium.firefox.internal.Executable.locateFirefoxBinaryFromSystemProperty()

  方法第一句

  String binaryName = System.getProperty("webdriver.firefox.bin");

  說明默認的時候取的就是這個值,重新設置一下。


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

運行后出現這樣的提示,怎么解決

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號