(2022 NOTE: Steps from this 2019 tutorial from Boston Code Camp are now out-of-date. For installing Jenkins from the Azure Marketplace, you can try using Bitnami Jenkins. Or, for the newer official Microsoft tutorial, see Get Started: Install Jenkins on an Azure Linux VM, and then continue with Step 4 below to resume SeleniumBase setup after you've created your Jenkins instance.)
Step 0. Fork the SeleniumBase repo on GitHub to get started quickly.
- (You'll be using your own repository eventually.)
Search for "Jenkins" in the Azure Marketplace and select the Jenkins (Publisher: Microsoft)
result to get to the Jenkins Start page.
- Use that IP Address to SSH into the machine:
ssh USERNAME@IP_ADDRESS
cd /
sudo git clone https://github.com/seleniumbase/SeleniumBase.git
cd SeleniumBase/integrations/linux/
Step 6. Give the "jenkins" user sudo access (See jenkins_permissions.sh for details)
./jenkins_permissions.sh
sudo su jenkins
bash
Step 8. Install dependencies (See Linuxfile.sh for details)
./Linuxfile.sh
Step 9. Start up the headless browser display mechanism: Xvfb (See Xvfb_launcher.sh for details)
./Xvfb_launcher.sh
cd /SeleniumBase
Step 11. Install the requirements for SeleniumBase
sudo pip install -r requirements.txt --upgrade
sudo python setup.py develop
sudo seleniumbase install chromedriver
Step 14. Run an example test in Chrome to verify installation (May take up to 10 seconds)
pytest examples/my_first_test.py --headless --browser=chrome
(Depending on your version of Jenkins, you may see the following screen, or nothing at all.)
- To do this, copy/paste the string and run it in a NEW command prompt on your local machine (NOT from an SSH terminal session), swapping out the username and DNS name with the ones you set up when creating the Jenkins instance in Azure.
ssh -L 127.0.0.1:8080:localhost:8080 USERNAME@DNS_NAME
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Click on "New Item"
- Give your new Jenkins job a name (ex: "Test1")
- Select "Freestyle project"
- Click "OK"
- Under "Source Code Management", select "Git".
- For the "Repository URL", put:
https://github.com/seleniumbase/SeleniumBase.git
. (You'll eventually be using your own clone of the repository here.)
- Under "Build", click the "Add build step" dropdown.
- Select "Execute shell".
- For the "Command", paste:
cd examples
pytest my_first_test.py --headless
- You'll see the following page after that:
- Click on "Build Now"
- (If everything was done correctly, you'll see a blue dot appear after a few seconds, indicating that the test job passed.)
If you have a web application that you want to test, you'll be able to create SeleniumBase tests and add them to Jenkins as you saw here. You may want to create a Deploy job, which downloads the latest version of your repository, and then kicks off all tests to run after that. You could then tell that Deploy job to auto-run whenever a change is pushed to your repository by using: "Poll SCM". All your tests would then be able to run by using: "Build after other projects are built".