I was hoping to get a web automation test script working on an AWS EC2 instance running Ubuntu 16.04 LTS with Ruby; Capybara and Cucumber frameworks.
I am intending to use Selenium-Webdriver as my web-driver (as opposed to waitr) and have also included Google's Chromedriver (Downloaded and extracted to the /usr/bin/
directory. and added to the server's $PATH
variable.)
I am also intending to run this headlessly via Jenkins (as this is an AWS virtual server, it does not have any kind of GUI)
I am including the code being used. Please Note: I am attempting this in Ruby, but not rails!
ActiveSupport::Dependencies.autoload_paths << File.expand_path(File.join(Dir.pwd, 'lib'))
Selenium::WebDriver::Chrome::Service.executable_path = '/usr/bin/chromedriver'
if ENV['IN_BROWSER']
# On demand: non-headless tests via Selenium/WebDriver
# To run the scenarios in browser (default: Firefox), use the following command line:
# IN_BROWSER=true bundle exec cucumber
# or (to have a pause of 1 second between each step):
# IN_BROWSER=true PAUSE=1 bundle exec cucumber
Capybara.default_driver = :selenium
Capybara.current_session.driver.browser.manage.window.resize_to(1800, 1000)
Capybara.register_driver :chrome do |app|
require 'selenium/webdriver'
profile = Selenium::WebDriver::Chrome::Profile.new
profile['browser.helperApps.alwaysAsk.force'] = false
profile['browser.cache.disk.enable'] = false
profile['browser.cache.memory.enable'] = false
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 240 # instead of the default 60
Capybara::Selenium::Driver.new(app, :browser => :chrome, :profile => profile, http_client: client)
end
else
...
When attempting to run this through Jenkins, I get the following error message:
not a file: "/usr/bin/chromedriver" (Selenium::WebDriver::Error::WebDriverError)
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/platform.rb:145:in `assert_file'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/platform.rb:150:in `assert_executable'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/chrome/service.rb:46:in `executable_path='
/var/jenkins_home/workspace/test/features/support/env.rb:12:in `<top (required)>'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `each'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:61:in `run!'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in `execute!'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/gems/cucumber-2.4.0/bin/cucumber:8:in `<top (required)>'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/bin/cucumber:23:in `load'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/bin/cucumber:23:in `<main>'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval'
/var/jenkins_home/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
Build step 'Execute shell' marked build as failure
I've not figured out why Jenkins is throwing up this message (I haven't even gotten to the part about the actual display (Which I'm using Xvfb to imitate a screen)) Can you help?
(Downloaded and extracted to the /usr/bin/ directory. and added to the server's $PATH variable.)
- My original post - I think I have, but then; I could be in the Matrix