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
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.
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.
Related
I'm trying to run a ruby file that uses capybara and selenium.
When I run cucumber, I get the error :
cannot load such file -- capybara (LoadError)
I saw in another answer that, in order to solve this problem, I had to install poltergeist, but when I run - gem install poltergeist
, I get the error ERROR: While executing gem ... (ArgumentError)
wrong number of arguments (given 1, expected 0)
Any help will be appreciated
You need to include/install the capybara gem, not poltergeist.
I recommend running cucumber with params -v -b , so that you can see where it's failed with verbose & backtrace log.
cucumber -v -b <your_cucumber_features/tag>
The message
cannot load such file -- capybara (LoadError)
was prompted when you've defined to use capybara in your ruby file but your machine hasn't been installed that gem. So need installing capybara via
gem install capybara
However, gem will be installed to specific RVM, so that if you have any error, then try to see which Ruby version that you install onto your system. I suggest install rbenv so that you can manage it better.
My Ruby environment was working sometime ago, but it broke so I'm trying to set it up again. I'm following these instructions. https://www.agiletrailblazers.com/blog/the-5-step-guide-for-selenium-cucumber-and-gherkin
I installed Ruby2.33 and extracted the dev kit to the same folder. I ran these installs with no problem. They all said gems were installed successfully
ruby dk.rb init
ruby dk.rb install
gem install bundler
gem install selenium-webdriver -v 3.2.1
gem install cucumber
gem install rspec
I create a .rb file in a separate folder and running the script is supposed to open firefox, navigate to the website and close the browser. All it does is open a blank firefox browser and it doesn't close.
My script is
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://mock.agiletrailblazers.com/"
driver.quit
I'm getting the below error
I also tried gem install webdrivers. My firefox install is inside my program files as well.
Anyone know why I can't run my script after all these commands and installs worked fine?
I tried to run a simple script as follows to learn automation using watir-webdriver and Ruby. But I am getting no such class error -ffi_c.
class TestWatir
require 'watir-webdriver'
require 'cucumber'
browser = Watir :: Browser.new :firefox
browser.goto 'http://www.google.com'
end
I've added Cucumber and Watir-webdriver gems and also checked there is ffi dependency in the external library.
I had this problem and resolved it by:
del Gemfile.lock
bundle clean --force
gem install bundler -v 1.12.1
gem install ffi -v 1.9.10 --platform=ruby
bundle install
It seams that some versions of ffi era labeled with the incorrect platform or something like that, that's bringing some problems on windows.
Hope it helps!
I have problem with moving Ruby on Rails app between two machines,
Both of them have exactly the same OS and setup (Arch linux x86_64 updated today),
(well, this can not be true, because this problem happens, but I'm unable to spot any differences at the moment)
both have rails in version 3.2.12 and ruby 1.9.3
On my laptop everything works fine, app runs correctly,
on desktop command
rake assets:precompile
fails with error:
/usr/bin/ruby /usr/bin/rake assets:precompile:all RAILS_ENV=development RAILS_GROUPS=assets
rake aborted!
couldn't find file 'jquery'
(...)
I have this in my application.js:
//= require jquery
//= require jquery_ujs
//= require_tree .
and gem 'jquery-rails' in my Gemfile (bundle install completes successfully)
but this is probably irrelevant - rake fails in exactly same wqay without this gem installed.
I tried running rails server, webpage shows error:
cannot load such file -- sass
(in [path])
Problem must lay somewhere in my ruby/rails installation on desktop, app source is kept in git, both machines have the same revision with clean working dir - tmp is in .gitignore.
Asset pipeline is enabled in config/application.rb
I tried the following:
Deleted tmp directory
Reinstalled rails, jquery and couple of other gems
Used other environments (rake fails in all of them)
Downloaded jquery and put it in assets dir (this is supposed to be automatic in rails),
i this case rake assets:precompile fails on sass stylesheet compilation (I have sass-rails installed!)
I must be missing something obvious here, anyone had this problem before?
Do I need to purge my ruby installation or is there a simpler way to solve this?
(ps. Sorry about my poor English)
We've been running integration tests successfully against Rails 2 using Selenium on both chrome and firefox. However, we've recently upgraded to Rails 3 and are running into issues creating a chrome webdriver instance.
When we attempt to create, we get the following stack:
irb(main):002:0> profile = Selenium::WebDriver::Chrome::Profile.new
translate])#<Selenium::WebDriver::Chrome::Profile:0x64f2fd0 #extensions=[], #model=nil>
irb(main):003:0> profile['download.prompt_for_download'] = false
false
irb(main):004:0> driver = Selenium::WebDriver.for(:chrome, :profile => profile, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate])
ArgumentError: wrong number of arguments (0 for 1)
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:157:in `open'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:157:in `ip'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:170:in `interfaces'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/port_prober.rb:23:in `free?'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/port_prober.rb:5:in `above'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/chrome/service.rb:33:in `default_service'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/chrome/bridge.rb:14:in `initialize'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/driver.rb:37:in `new'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/driver.rb:37:in `for'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver.rb:67:in `for'
from (irb):4
Any tips?
I saw this when I had included a gem which included the "backports" gem as part of its dependencies into my Gemfile. The backports gem rewrites some Ruby 1.8 internals, which overwrote parts of the UDPSocket core class. Try getting rid of the backports gem and giving it a shot.
ChromeDriver Installation:
Download Chromedriver 2.x from "http://chromedriver.storage.googleapis.com/index.html?path=2.8/." Unzip it and save it in a folder on any drive. Set path by following steps :
Copy the path till chromedriver.exe
Right click on Computer and select ‘Properties’
Select ‘Advanced system variables’
Select ‘Environment variables’
Click on Edit button for ‘Path’ variable of ‘User variables’
Append the chromedriver path
Save changes.
Run Selenium Test :
Now run your selenium test. It will run on the chrome browser.
Sample Code
require 'selenium-webdriver'
$driver = Selenium::WebDriver.for :chrome
$driver.navigate.to "https://www.google.co.in/"
$driver.manage().window().maximize()
$driver.quit()
NOTE : You need to install latest chromedriver for latest version of Chrome browser
This was caused by an interference with the backports gem and the fact that the socket library reuses IO.open although it changes the interface.
Upgrading backports to v2.6.7 or above should resolve this.