Last active
June 28, 2016 16:15
-
-
Save gavinengel/e981e9c57a97d2deed5a to your computer and use it in GitHub Desktop.
Headless Selenium tests on your server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# you want to be able to do browser testing, but in an automated way. here is how! | |
# Step 1: create your selenium script, using https://saucelabs.github.io/sb-sauce-plugin/, Firefox, and your text editor. | |
# Step 2: install some npm's: | |
# I was able to install selenium-standalone without sudo, using this method https://gist.github.com/gavinengel/1842179837823dc25730 | |
lib; | |
npm install selenium-standalone; | |
selenium-standalone install; | |
selenium-standalone start; | |
# leave this running! | |
# I had to use sudo for phantomjs: | |
cd; | |
sudo npm install phantomjs -g; | |
# I was also able to install se-interpreter without sudo, using my sudoless-npm gist: | |
lib; | |
npm install se-interpreter; | |
# Step 3: run it! | |
se-interpreter /home/gavin/se-test.json --browser-browserName=phantomjs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gavin@engeldev:~/bin/node/lib$ se-interpreter /home/gavin/se-test.json --browser-browserName=phantomjs | |
SE-Interpreter 1.0.7 | |
se-test: Starting test (phantomjs) se-test | |
se-test: Success {"type":"get","url":"https://en.wikipedia.org/wiki/Selenium"} | |
se-test: Success {"type":"clickElement","locator":{"type":"link text","value":"vitamin E"}} | |
se-test: Success {"type":"clickElement","locator":{"type":"link text","value":"ethanol"}} | |
se-test: Success {"type":"clickElement","locator":{"type":"link text","value":"sugar cane"}} | |
se-test: Success {"type":"clickElement","locator":{"type":"link text","value":"New Guinea"}} | |
se-test: Success {"type":"verifyText","locator":{"type":"css selector","value":"h1"},"text":"New Guinea"} | |
se-test: Test passed | |
1/1 tests ran successfully. Exiting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "script", | |
"seleniumVersion": "2", | |
"formatVersion": 2, | |
"steps": [ | |
{ | |
"type": "get", | |
"url": "https://en.wikipedia.org/wiki/Selenium" | |
}, | |
{ | |
"type": "clickElement", | |
"locator": { | |
"type": "link text", | |
"value": "vitamin E" | |
} | |
}, | |
{ | |
"type": "clickElement", | |
"locator": { | |
"type": "link text", | |
"value": "ethanol" | |
} | |
}, | |
{ | |
"type": "clickElement", | |
"locator": { | |
"type": "link text", | |
"value": "sugar cane" | |
} | |
}, | |
{ | |
"type": "clickElement", | |
"locator": { | |
"type": "link text", | |
"value": "New Guinea" | |
} | |
}, | |
{ | |
"type": "verifyText", | |
"locator": { | |
"type": "css selector", | |
"value": "h1" | |
}, | |
"text": "New Guinea" | |
} | |
], | |
"data": { | |
"configs": {}, | |
"source": "none" | |
}, | |
"inputs": [], | |
"timeoutSeconds": 60 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment