Here I’ve released one open docker image in docker hub and github.
GitHub
It has everything you need to run a test against page loading:
- Packages: selenium server, Chrome driver, python SDK
- Scripts: seleniumloadpage.py, which runs the actual page loading tests.
How to run GUI test in my local machines?
- Step1: Install docker daemon in your machines. Super easy with docker doc[6], right?.
- Step2: Run below commands to perform a helloworld test case.
That’s it!
# Start selenium docker container
# docker stop selenium; docker rm selenium
mkdir -p /tmp/screenshot && chmod 777 /tmp/screenshot
docker run -d -p 4444:4444 -v /tmp/screenshot:/tmp/screenshot \
-h selenium --name selenium denny/selenium:v1
docker ps
# wait for selenium service to be up and running
sleep 5
# Test page loading
docker exec selenium python selenium_load_page.py \
--page_url "https://www.dennyzhang.com"
# Check generated screenshot
ls -lth /tmp/screenshot
# Destroy selenium container, after testing
docker stop selenium; docker rm selenium
seleniumloadpage.py should be able to solve most of your problems.
Please leave me comments, if I’m too proud of this script.
(Note: About login pages which requires credential. Yes, we do need some work. PRs or input are warmly welcomed.)
## Sample:
## - Test page load: basic test
## python ./selenium_load_page.py --page_url https://www.dennyzhang.com
##
## - Test page load: if it takes more than 5 seconds, fail the test. Default timeout is 10 seconds
## python ./selenium_load_page.py --page_url https://www.dennyzhang.com --max_load_seconds 5
##
## - Test page load: after page loading, save screenshot
## python ./selenium_load_page.py --page_url https://www.dennyzhang.com --should_save_screenshot true
If you’re selenium ninja, you can definitely create your own test scripts. Login the docker container and do whatever your want.
Please don’t forget to share this post to your QA or DevOps colleagues, if you think it’s helpful for your projects. Thanks, my friend!
[1] http://www.webdesignerdepot.com/2016/02/how-slow-is-too-slow-in-2016/
[2] https://developer.chrome.com/devtools
[3] http://justniffer.sourceforge.net/#!/examples
[4] http://docs.seleniumhq.org/projects/ide/
[5] https://hub.docker.com/r/denny/selenium/
[6] https://docs.docker.com/manuals/
Related Reading:


Blog URL: https://www.dennyzhang.com/selenium_docker