Hi,
has anyone experiences to get SeleniumHQ or Watir running on a Turnkey Lamp?
I just install ruby and ruby-dev and the watir-webdriver or selenium-webdriver. But it is not easy the get an inspector like firefox or chrome running on the lamp, because there is no X.
Has anyone an idea to get it running.
Thanks!!!
Replies (5)
Hi there.
Reply 1Thanks
Reply 2I'm now testing selenium or watir with the headless extension (https://github.com/leonid-shevtsov/headless). It works fine on ubuntu. But i will integrated in the turnkey lamp, but there are some difficulties to get firefox running.
Thanks for help!
HowTo
Reply 3Here a summary to get watir working on turnkey lamp:
Install Firefox:
echo -e "\ndeb http://downloads.sourceforge.net/project/ubuntuzilla/mozilla/apt all main" | tee -a /etc/apt/sources.list.d/sources.list > /dev/null apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C1289A29 apt-get update apt-get install libgtk-3-0 apt-get install firefox-mozilla-build
Download and install geckodriver from here: https://github.com/mozilla/geckodriver/releases
Install Watir:
apt-get install ruby ruby-dev gem install watir
Install headless:
apt-get install xvfb gem install headless
Now you can use firefox for headless web testing with ruby like this:
require "rubygems" require "headless" require "watir" # start firefox headless headless = Headless.new headless.start browser = Watir::Browser.new :firefox browser.goto "http://www.google.de" html = browser.html ... headless.destroy
This is working fine. I'm now trying to get it workking with google chrome ...
Thanks for sharing! :)
Reply 4Update with chrome
Reply 5I found now a way to use chrome/chromium for web testing.
Install chrome:
sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - apt-get update apt-get install google-chrome-stable
Install chromium:
apt-get install chromium
You need both google-chrome and chromium. Google-chrome is not running, but is neccessary for the gnomedriver for watir. Chromium is running with parameter --no-sandbox:
chromium --no-sandbox
Download and install chromedriver from here: https://sites.google.com/a/chromium.org/chromedriver/
Install watir and headless.
Now you can use chrome for headless web testing (with disabled image download) with ruby like this:
require "rubygems" require "headless" require "watir" # start chrome headless headless = Headless.new headless.start # chrome disable load images profile = Selenium::WebDriver::Chrome::Profile.new profile['webkit.webprefs.loads_images_automatically'] = false # start Browser browser = Watir::Browser.new :chrome, :profile => profile, :switches => %w[--no-sandbox] browser.goto "http://www.google.de" html = browser.html ... headless.destroy
Works fine ... and it's quite faster than firefox ...
IIRC there is a way to run it headlessly using headless webkit and/or something like PhantomJS. Actually a quick google bought up this page which looks relevant?!