My selenium webdriver 'hello world' program is failing. Please advise.
I spun up a new Ubuntu image and here is my setup:
- Ubuntu 18.04 with Google Chrome installed
- Ruby on Rails
- selenium-webdriver gem installed
- VNC is installed
My 'hello world' program:
require "selenium-webdriver"
**driver = Selenium::WebDriver.for :chrome**
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello Selenium WebDriver!"
element.submit
puts driver.title
This spits out the error:
/home/user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/response.rb:72:in `assert_ok': unknown error: Chrome failed to start: exited abnormally (Selenium::WebDriver::Error::UnknownError) (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 5.0.0-1028-gcp x86_64)
(This error happens at the boldfaced line of code)
I checked with whereis command for google-chrome and google-chrome-stable. They are both in /usr/bin/
I also have VNC installed and I am looking at the operating system. When I run this program, I am hoping for Chrome to pop out but nothing happens.
Is Selenium supposed to start chrome (visible to me in VNC)? In any case, what am I doing wrong?