2017-09-13 36 views
1

對於那些不知道的人來說,c9是一個使用雲的在線IDE。所以,我試圖使用Firefox的Watir,我得到的錯誤是如何在使用c9時在Rails中設置Firefox二進制文件的路徑?

「找不到Firefox的二進制(OS = Linux系統)確保已安裝的Firefox 或 硒手動設置路徑:: ::的webdriver火狐:: Binary.path =」

當我檢查我的電腦對Firefox的文件路徑正是這種電腦/ Windows(C:)/ Program Files文件/ Mozilla Firefox瀏覽器

這是我的代碼,我正在使用

def save 
    require 'watir' 
    require 'firefox' 

    @browser = Watir::Browser.new :firefox 
    @browser.goto "https://kroger.softcoin.com/programs/kroger/digital_coupons/?origin=DigitalCoupons&banner=Smiths#contentBox" 

    @browser.div(id: "contentBox").wait_until(&:present?).text 

    # Could not find Firefox binary (os=linux). 
    # Make sure Firefox is installed or set the path manually with 
    # Selenium::WebDriver::Firefox::Binary.path= 
    # ThisPC:WindowsC:ProgramFiles:MozillaFireFox 

    @products = @browser.divs 

end 
+0

你有沒有使用geckodriver –

回答

1

嘗試添加下面的代碼:

require 'selenium-webdriver' 
Selenium::WebDriver::Firefox::Binary.path='C:/Program Files/Mozilla FireFox/firefox.exe' 

另外,你需要geckodriver添加爲更高版本firfox沒有geckodriver從下面的網址不支持

下載geckodriver: -

https://github.com/mozilla/geckodriver/releases

您還需要添加geckodrover的路徑如下:

export PATH=$PATH:/path/to/geckodriver 

參考:

https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver

另請參考: -

https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings

這是爲我工作的Java代碼如下:

System.setProperty("webdriver.gecko.driver", "C:\\abc\\geckodriver.exe"); 
WebDriver driver = new FirefoxDriver(); 
driver.manage().window().maximize(); 
driver.get("http://gmail.com"); 

希望它會幫你

+0

得到錯誤「不是文件:」C:/ Program Files/Mozilla FireFox/firefox.exe「。儘管謝謝你的回覆。 – ChrisWilson

+0

你的firefox安裝在同一個位置。你有沒有檢查? ..你正在使用geckodriver,正如我在回答中提到的那樣? –

+0

https://github.com/SeleniumHQ/selenium/wiki/Ruby-Bindings –

相關問題