Trước đó tôi đã đặt nhị phân Chrome, "chromedriver.exe", trong thư mục "C:/Windows" và Watir đã chọn nó từ đó. Bây giờ tôi phải di chuyển dự án của mình sang một máy khác để tôi không thể mã hóa đường dẫn thực thi. Tôi cũng muốn các mã nhị phân được lưu giữ với mã của chúng tôi trên Git thay vì làm cho mỗi kỹ sư kiểm tra cập nhật thủ công nhị phân khi các phiên bản mới hơn được phát hành.Cách xác định vị trí của nhị phân chromedriver
Bây giờ tôi đã đặt nhị phân Chrome ở đường dẫn tuyệt đối, nhưng không tìm thấy nó. Đây là những gì tôi đã cố gắng (hooks.rb):
Before do
puts "inside hooks in before"
profile = Selenium::WebDriver::Chrome::Profile.new
profile['download.prompt_for_download'] = false
profile['download.default_directory'] = File.join(File.absolute_path('../..', File.dirname(__FILE__)),"browsers/chromedriver.exe")
@browser = Watir::Browser.new :chrome, :profile => profile
end
Đầu ra là:
inside hooks in before
Selenium::WebDriver::Error::WebDriverError: Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver.
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/chrome/service.rb:21:in `executable_path'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/chrome/service.rb:34:in `default_service'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/chrome/bridge.rb:14:in `initialize'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/driver.rb:37:in `new'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/driver.rb:37:in `for'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver.rb:67:in `for'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.11/lib/watir-webdriver/browser.rb:46:in `initialize'
C:/Users/Admin/watircukepractice/test_puppies/features/support/hooks.rb:11:in `new'
C:/Users/Admin/watircukepractice/test_puppies/features/support/hooks.rb:11:in `Before'
Tôi đang trên Windows 7, Sử dụng Ruby phiên bản 1.9.3p551 và tôi đang đề cập đến hướng dẫn http://watirwebdriver.com/chrome/.
Làm cách nào để nói với Watir (và Selenium-WebDriver) vị trí của chromedriver.exe?
Os của bạn có 32 BIT hoặc 64 BIT? –
Hệ điều hành của tôi là 64 bit – paul
trình điều khiển bạn đã đặt trong đường dẫn đó từ danh sách này: http://chromedriver.storage.googleapis.com/index.html?path=2.13/ –