LoadError: cannot load such file — selenium/webdriver/phantomjs

狂风中的少年 提交于 2019-12-19 08:59:41

问题


I have this code in my Cucumber Hooks file to run the ghost driver it was working until yesterday I start seeing the error message:

Before do
  Selenium::WebDriver::PhantomJS.path = 'C:\phantomjs-2.1.1-windows\bin\phantomjs.exe'
  @browser = Watir::Browser.start "https://www.google.com",  :phantomjs
  @browser.window.maximize    
end

Error message:

LoadError: cannot load such file -- selenium/webdriver/phantomjs

回答1:


Yes, we've removed support for PhantomJS as of Selenium 3.8. The PhantomJS project is no longer being maintained. If you actually do need headless, please investigate either the Chrome or Firefox headless options.




回答2:


For those who encounter this error, you can work around it by locking your selenium-webdriver version in your Gemfile like so:

gem 'selenium-webdriver', '~> 3.6.0'

and then bundle update to downgrade.

(You may not even have selenium-webdriver specified in your Gemfile currently if it's just being loaded as a dependency of watir or some other library.)

The long term fix, of course, is to move off of PhantomJS to Chrome or Firefox headless.



来源:https://stackoverflow.com/questions/47711301/loaderror-cannot-load-such-file-selenium-webdriver-phantomjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!