This repository contains the Robot Framework Demo workspace. The following topics are covered:
Demo Directory | Description |
---|---|
Demo1_Basic |
robot framework scripts using the keywords from libraries |
Demo2_Refactored |
variables and keywords into Variables and Keywords sections respectively |
Demo3_Composite |
separation of variables, keywords into different .robot files and creation of higer level keywords |
Demo4_Extended |
extending robot framework for jenkins, report portal, docker-selenium. added option for headless chrome test exection and creation of higher level keywords |
Directory | Description |
---|---|
common |
contains custom Robot Framework libraries and keywords that will be used by the test suites. |
DockerFiles |
contains the docker compose file for docker-selenium |
JenkinsFiles |
contains the Jenkins file using declarative pipeline syntax for test execution in parallel |
common\custom_libraries |
contains the custom libraries |
common\global_resources |
contains the step definitions, test data and global reusable keywords |
Demo4_Extended |
contains the workspace for the composite and extended robot framework for http://automationpractice.com |
Demo4_Extended\src\demo\resources |
contains the keywords specific for Demo4_Extended |
Demo4_Extended\src\demo\resources |
contains the test suites for Demo4_Extended |
Demo4_Extended\src\demo\suite\availability |
test suites with test cases for checking pages' availability. assert that all page's elements are visible |
Demo4_Extended\src\demo\suite\functionality |
test suites with test cases checking pages' functionality |
Demo4_Extended\src\demo\suite\endtoend |
test suites with end to end test cases |
Results |
directory for report and logs, created on run time |
File | Description |
---|---|
setup.py |
prerequisite installation files |
gitignore |
list of files to be ignored for git |
argument_file.robot |
run time arguments |
README.md |
read me file |
- Web Drivers: chromedriver, geckodriver
- Python 2.7
- Git
- Sublime Text 2 or any text editor
-
Web browsers. Note the supported web browser version for web drivers
-
git repository for your code
- if you are running onJenkins pipeline
- Jenkins war file
- Java
- [Sauce Labs] (https://saucelabs.com/)
- Docker
- docker-Selenium, dockerised Selenium Grid
- Report Portal
- Phabricator
- archanist, the command line tool for Phabricator
Note: This setup is for MacOS or Ubuntu. For windows, kindly setup these values in Environment Variables.
- Download the web drivers
- Extract the files in a local directory then run the following scripts:
# Chmod to executable file
chmod +x ~/Downloads/chromedriver
# Move the file from Downloads folder to share folder
sudo mv -f ~/Downloads/chromedriver /usr/local/share/chromedriver
# Create a symlink
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
- Do the same steps for geckodriver
- Add the following in the bash_profile
# Edit bash_profile
sudo nano ~/.bash_profile
# Web drivers
export CHROMEDRIVER="/usr/local/bin/chromedriver"
export PATH=$PATH:$CHROMEDRIVER
export GECKODRIVER="/usr/local/bin/geckodriver"
export PATH=$PATH:$GECKODRIVER
- Save the changes to bash_profile.
- Source the bash_profile
source ~/.bash_profile
Clone this repository to your local directory.
Open a terminal and cd to RobotFrameworkDemoWorkspace
where setup.py is located.
Run the following in the terminal:
pip install -e .
Or
sudo pip install -e .
Note: An error may sometimes occur, either rerun the pip install script or search and troubleshoot according to the error message.
Method | Script |
---|---|
Run all tests in a directory | robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome Demo4_Extended |
Run a specific test via filename | robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome Demo3_Composite/DemoCompositeLogintTest.robot |
Run tests by suite | robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome -s HomePageAvailabilityTest . |
Run tests by tag | robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome -i REGRESSION . |
Run tests via tag wildcards | robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome -i Login* . |
Source your bash_profile via the following script in the terminal.
source ~/.bash_profile
Include the argument_file.txt
found at the top-level directory for non-changing arguments on run time.
To run a particular test suite, using the same terminal where the bash_profile was sourced, run the following:
robot --argumentfile argument_file.robot --variable BROWSER:chrome --variable BASE_URL:http://automationpractice.com --variable REMOTE_URL:False --suite AddProductToCartTest .
Tests may also be filtered using tags defined in a test suite's Default Tags
, Force Tags
or in the Test Case
level tags
setting table:
robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome -v REMOTE_URL:False -v HEADLESS_CHROME:True -i REGRESSION .
Running in Headless Chrome.
Set HEADLESS_CHROME
to True
.
robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome -v HEADLESS_CHROME:True -i LoginTest .
Running in non-headless Chrome.
Set HEADLESS_CHROME
to False
.
robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome -v HEADLESS_CHROME:False -i DataDrivenLoginTest .
Or remove the variable HEADLESS_CHROME
robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:chrome -i DataDrivenLoginTest .
Running tests in firefox
or other browsers, update the BROWSER
value to the applicable browser.
robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:firefox -v REMOTE_URL:False -i DataDrivenLoginTest .
Running tests in Selenium Grid, set REMOTE_URL
to TRUE
or to Selenium Grid URI: http://localhost:4444/wd/hub
NOTE: Run selenium grid first.
docker-compose -f DockerFiles/docker-compose.yml up
Then run the script on Remote URL using the following script.
robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:firefox -v REMOTE_URL:True -i DataDrivenLoginTest .
Or
robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:firefox -REMOTE_URL:http://localhost:4444/wd/hub -i DataDrivenLoginTest .
Running tests in Sauce Labs, set REMOTE_URL
to the Saucelabs URI: saucelabs
NOTE: Creat a Sauce Labs account then save the Sauce Labs Username and Access Key as environment variables.
GET SAUCELABS DETAILS:
- Signup with Sauce Labs:
https://saucelabs.com
. - Sign in to Sauce Labs.
- Click user icon on top right.
- Go to
User Settings
> ClickShow
. - Input user password And click the Access key (which is then AutomAticAlly copied toclipboArd).
- Get the Sauce labs remote URL.
- Go to Dashboard > AUTOMATED TESTS tab And copy the URI in the instructions:
http://ondemand.saucelabs.com/wd/hub
.
Save the sauce labs credentials in bash_profile
export SAUCE_USERNAME="<your username>"
export PATH=$PATH:$SAUCE_USERNAME
export SAUCE_ACCESS_KEY="<your sauce labs access key>"
export PATH=$PATH:$SAUCE_ACCESS_KEY
Then run the script on Remote URL using the following script.
robot -A argument_file.robot -v BASE_URL:http://automationpractice.com -v BROWSER:firefox -v REMOTE_URL:http://ondemand.saucelabs.com/wd/hub -i DataDrivenLoginTest .
Note: This setup is for mac or ubuntu. For windows, kindly setup these values in Environment Variables
- Download Jenkins war file.
- Extract and move war file to
/etc/jenkinswarfile
directory.
sudo mv -f ~/Downloads/jenkins.war /etc/jenkinswarfile
- Update
bashrc
orbash_profile
sudo nano ~/.bash_profile
- Add the following in the bash_profile
# Jenkins
export JENKINWARFILE="/etc/jenkinswarfile"
export PATH=$PATH:$JENKINWARFILE
# Java
export JAVA_HOME_8_X64="/usr/bin/java"
export PATH=$PATH:$JAVA_HOME_8_X64
- Save the changes to bash_profile.
- Run Jenkins. Use any available port
java -jar jenkins.war --httpPort=9090
- Open http://localhost:9090, then create a
Pipeline
. Go toNew Item
>Pipeline
. - Enter a name in the
Enter an item name
textfield then clickOK
. - Scroll down and select
Pipeline script from scm
as Definition in thePipeline
section. - Select
Git
in theSCM
field. - Fillout the
Repository URL
with your git workspace uri. For this example:https://github.com/enhanceTAfrancis/RobotFrameworkDemoWorkspace.git
. - Fillout the Credentials field with your github credentials.
- Fillout the
Script Path
text field. For this example:JenkinsFiles/pipelinetestrunner
. - Click Save.
Build
the pipeline you created. The build will initially fail.- Rerun the build, and the build button should now be
Build with Parameters
. - Click
Build
- Install Docker
- Clone the docker-selenium repo.
git clone https://github.com/SeleniumHQ/docker-selenium.git
- Build the images. cd to the
docker-selenium
directory, then run:
VERSION=local make build
- Display all docker images and take note of the created images:
docker image ls
- Run the hubs and nodes. cd to the
RobotFrameworkDemoWorkspace\DockerFiles
.
docker-compose -f docker-compose.yml up
Prerequisite: Sublime Text 2 is installed
- Go to https://packagecontrol.io/installation
- Download Package Control.sublime-package
- Click the
Preferences > Browse Packages…
menu - Browse up a folder and then into the
Installed Packages/
folder - Copy
Package Control.sublime-package
toInstalled Packages/
folder - Restart
Sublime Text 2
- Click on
Preferences > Package Control
menu - Type
Install Package
then selectInstall Package
from the list. Wait for the installation to complete. - After installation, another list will be displayed. Type
Robot Framework Assistant
and press Enter. - Restart Sublime.
Robot Framework
Menu should be visible.