Last modified: 2013-12-21 17:02:28 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T60035, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 58035 - Run Selenium tests on Cloudbees using PhantomJS
Run Selenium tests on Cloudbees using PhantomJS
Status: RESOLVED FIXED
Product: Wikimedia
Classification: Unclassified
Quality Assurance (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Željko Filipin
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-05 15:19 UTC by Željko Filipin
Modified: 2013-12-21 17:02 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Željko Filipin 2013-12-05 15:19:53 UTC

    
Comment 1 Željko Filipin 2013-12-05 15:26:09 UTC
This installs phantomjs in ./phantomjs-1.9.2-linux-x86_64/bin/phantomjs

curl -O https://phantomjs.googlecode.com/files/phantomjs-1.9.2-linux-x86_64.tar.bz2
tar xvf phantomjs-1.9.2-linux-x86_64.tar.bz2

This opens the browser, opens a page and takes a screen shot

require "selenium-webdriver"
Selenium::WebDriver::PhantomJS.path = "./phantomjs-1.9.2-linux-x86_64/bin/phantomjs"
browser = Selenium::WebDriver.for :phantomjs
browser.navigate.to "http://cloudbees.com"
browser.save_screenshot "cloudbees.png"
Comment 2 Željko Filipin 2013-12-05 15:28:07 UTC
Installing phantomjs via curl requires that it is installed every time a job is executed.

If the browser is installed via npm then it can be reused between job runs, and maybe even between jobs.

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.11.8 . ./use-node
npm install phantomjs
Comment 3 Željko Filipin 2013-12-09 14:18:55 UTC
Looks like this is the way to go:

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.11.8 . ./use-node
npm install phantomjs

mkdir -p $HOME/bin
ln -Fs /scratch/jenkins/workspace/phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs $HOME/bin/phantomjs

curl -s -o use-ruby https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/ruby/use-ruby
RUBY_VERSION=2.0.0-p247 \
  source ./use-ruby

gem install selenium-webdriver --no-ri --no-rdoc
ruby test.rb
Comment 4 Željko Filipin 2013-12-10 14:17:15 UTC
To avoid:

ln -Fs /scratch/jenkins/workspace/phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs /home/jenkins/bin/phantomjs
ln: failed to create symbolic link `/home/jenkins/bin/phantomjs': File exists

Use if:

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.11.8 . ./use-node
npm install phantomjs

mkdir -p $HOME/bin

if [ ! -f $HOME/bin/phantomjs ] 
  then
    ln -Fs /scratch/jenkins/workspace/phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs $HOME/bin/phantomjs
fi
Comment 5 Željko Filipin 2013-12-10 14:55:02 UTC
According to http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html, -h should be used instead of -f.

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.11.8 . ./use-node
npm install phantomjs

mkdir -p $HOME/bin

if [ ! -h $HOME/bin/phantomjs ] 
  then
    ln -Fs /scratch/jenkins/workspace/phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs $HOME/bin/phantomjs
fi
Comment 6 Željko Filipin 2013-12-10 17:40:29 UTC
Getting somewhere, finally:

https://wmf.ci.cloudbees.com/view/fs/job/free-style-UniversalLanguageSelector-commons.wikimedia.beta.wmflabs.org-linux-phantomjs/17/console

...
ruby -r selenium-webdriver -e 'browser = Selenium::WebDriver.for :phantomjs; browser.navigate.to "https://www.google.com/"; browser.save_screenshot "google.png"'
/scratch/jenkins/addons/ruby/ruby-2.0.0-p247-x86_64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.38.0/lib/selenium/webdriver/phantomjs/service.rb:20:in `executable_path': Unable to find phantomjs executable. (Selenium::WebDriver::Error::WebDriverError)
...
Comment 7 Željko Filipin 2013-12-10 18:04:30 UTC
Looks like this is the way to go:

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.11.8 . ./use-node
npm install phantomjs

mkdir -p $HOME/bin

if [ ! -h $HOME/bin/phantomjs ] 
  then
    ln -Fs ${WORKSPACE}/lib/phantom/bin/phantomjs $HOME/bin/phantomjs
fi

curl -s -o use-ruby https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/ruby/use-ruby
RUBY_VERSION=2.0.0-p247 \
  source ./use-ruby

gem install selenium-webdriver --no-ri --no-rdoc

ruby -r selenium-webdriver -e 'browser = Selenium::WebDriver.for :phantomjs; browser.navigate.to "https://www.google.com/"; browser.save_screenshot "google.png"'
Comment 8 Gerrit Notification Bot 2013-12-10 18:12:24 UTC
Change 100384 had a related patch set uploaded by Zfilipin:
WIP Updated Ruby gems

https://gerrit.wikimedia.org/r/100384
Comment 9 Gerrit Notification Bot 2013-12-10 18:13:22 UTC
Change 100375 had a related patch set uploaded by Zfilipin:
WIP Make it possible to run tests on Cloudbees using PhantomJS

https://gerrit.wikimedia.org/r/100375
Comment 10 Gerrit Notification Bot 2013-12-11 16:04:04 UTC
Change 100384 merged by jenkins-bot:
Updated Ruby gems

https://gerrit.wikimedia.org/r/100384
Comment 12 Željko Filipin 2013-12-11 19:17:54 UTC
Looks like this should do it:

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.11.8 . ./use-node
npm install phantomjs

mkdir -p $HOME/bin
if [ ! -h $HOME/bin/phantomjs ] 
  then
    ln -Fs $WORKSPACE/node_modules/phantomjs/lib/phantom/bin/phantomjs $HOME/bin/phantomjs
fi

phantomjs -v
Comment 13 Gerrit Notification Bot 2013-12-13 09:45:12 UTC
Change 100375 merged by jenkins-bot:
Make it possible to run tests on Cloudbees using PhantomJS

https://gerrit.wikimedia.org/r/100375
Comment 14 Željko Filipin 2013-12-21 17:02:28 UTC
The latest advice from Cloudbees support says this should be the way to go:

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.11.8 . ./use-node
rm $HOME/bin/phantomjs
npm install phantomjs
ln -fs $WORKSPACE/node_modules/phantomjs/lib/phantom/bin/phantomjs $HOME/bin/phantomjs
phantomjs -v

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links