├── .gitignore ├── requirements.txt ├── tutorial-images ├── tn.PNG ├── logo.PNG ├── rfpt.PNG ├── rfst.PNG └── rfsample.PNG ├── .gitpod.yml ├── Resources ├── LambdaTestStatus.py └── Common.robot ├── Makefile ├── Tests └── sample_test.robot └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | output.xml 2 | report.html 3 | log.html 4 | __pycache__ 5 | venv 6 | .idea -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | selenium == 4.38.0 2 | robotframework == 7.3.2 3 | robotframework-seleniumlibrary == 6.8.0 4 | -------------------------------------------------------------------------------- /tutorial-images/tn.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LambdaTest/Robot-Selenium-Sample/HEAD/tutorial-images/tn.PNG -------------------------------------------------------------------------------- /tutorial-images/logo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LambdaTest/Robot-Selenium-Sample/HEAD/tutorial-images/logo.PNG -------------------------------------------------------------------------------- /tutorial-images/rfpt.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LambdaTest/Robot-Selenium-Sample/HEAD/tutorial-images/rfpt.PNG -------------------------------------------------------------------------------- /tutorial-images/rfst.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LambdaTest/Robot-Selenium-Sample/HEAD/tutorial-images/rfst.PNG -------------------------------------------------------------------------------- /tutorial-images/rfsample.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LambdaTest/Robot-Selenium-Sample/HEAD/tutorial-images/rfsample.PNG -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | 2 | 3 | # List the start up tasks. You can start them in parallel in multiple terminals. See https://www.gitpod.io/docs/config-start-tasks/ 4 | tasks: 5 | - init: pip install -r requirements.txt 6 | command: make run_all_in_parallel 7 | -------------------------------------------------------------------------------- /Resources/LambdaTestStatus.py: -------------------------------------------------------------------------------- 1 | import os 2 | from robot.libraries.BuiltIn import BuiltIn 3 | 4 | def report_lambdatest_status(name, status): 5 | selenium = BuiltIn().get_library_instance('SeleniumLibrary') 6 | 7 | # Mark test status pass/failed 8 | lambda_status = "passed" if status=="PASS" else "failed" 9 | lambda_status_script = 'lambda-status={}'.format(lambda_status) 10 | selenium.execute_javascript(lambda_status_script) 11 | # Update test name 12 | lambda_status_script = 'lambda-name={}'.format(name) 13 | selenium.execute_javascript(lambda_status_script) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | run_all_in_parallel: 2 | make -j test_Windows_10_edge_latest test_firefox_latest test_Windows_10_chrome_latest 3 | 4 | test_Windows_10_edge_latest: 5 | robot --output NONE --report NONE --log NONE --variable browserName:MicrosoftEdge --variable version:latest --variable ROBOT_BROWSER:Edge Tests/sample_test.robot 6 | test_firefox_latest: 7 | robot --output NONE --report NONE --log NONE --variable browserName:Firefox --variable version:latest --variable ROBOT_BROWSER:Firefox Tests/sample_test.robot 8 | test_Windows_10_chrome_latest: 9 | robot --output NONE --report NONE --log NONE --variable browserName:Chrome --variable version:latest --variable ROBOT_BROWSER:Chrome Tests/sample_test.robot -------------------------------------------------------------------------------- /Tests/sample_test.robot: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | 3 | Resource ../Resources/Common.robot 4 | 5 | Test Setup Common.Open test browser 6 | Test Teardown Common.Close test browser 7 | 8 | *** Variables *** 9 | 10 | *** Test Cases *** 11 | 12 | Example of connecting to Lambdatest via Robot Framework 13 | [Timeout] ${TIMEOUT} 14 | Page should contain element name:li1 15 | Page should contain element name:li2 16 | 17 | Click button name:li1 18 | Click button name:li2 19 | 20 | Input text id:sampletodotext Yey Let's add it to list 21 | Click button id:addbutton 22 | ${response} Get Text xpath=/html/body/div/div/div/ul/li[6]/span 23 | Should Be Equal As Strings ${response} Yey Let's add it to list 24 | -------------------------------------------------------------------------------- /Resources/Common.robot: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | Library SeleniumLibrary 3 | Library LambdaTestStatus.py 4 | 5 | *** Variables *** 6 | ${BROWSER} ${ROBOT_BROWSER} 7 | &{lt_options} browserName=${browserName} name=RobotFramework Lambda Test buildName=Robot Build 8 | ${REMOTE_URL} http://%{LT_USERNAME}:%{LT_ACCESS_KEY}@hub.lambdatest.com/wd/hub 9 | ${TIMEOUT} 30000 10 | ${IMPLICIT_WAIT} 9seconds 11 | 12 | *** Keywords *** 13 | Open test browser 14 | [Timeout] ${TIMEOUT} 15 | ${options}= Evaluate sys.modules['selenium.webdriver'].${BROWSER}Options() sys, selenium.webdriver 16 | Call Method ${options} set_capability LT:Options ${lt_options} 17 | Open Browser https://lambdatest.github.io/sample-todo-app/ 18 | ... browser=${BROWSER} 19 | ... remote_url=${REMOTE_URL} 20 | ... options=${options} 21 | Set Selenium Implicit Wait ${IMPLICIT_WAIT} 22 | 23 | Close test browser 24 | Run keyword if '${REMOTE_URL}' != '' 25 | ... Report Lambdatest Status 26 | ... ${TEST_NAME} 27 | ... ${TEST_STATUS} 28 | Close All Browsers 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Run Selenium Tests With Robot On LambdaTest 2 | 3 | ![171934563-4806efd2-1154-494c-a01d-1def95657383 (1)](https://user-images.githubusercontent.com/70570645/172273386-fa9606ac-3e63-4b2e-8978-3142add3e038.png) 4 | 5 |

6 | Blog 7 |   ⋅   8 | Docs 9 |   ⋅   10 | Learning Hub 11 |   ⋅   12 | Newsletter 13 |   ⋅   14 | Certifications 15 |   ⋅   16 | YouTube 17 |

18 |   19 |   20 |   21 | 22 | *Learn how to run your Python automation testing scripts using Robot on the LambdaTest platform* 23 | 24 | [](https://accounts.lambdatest.com/register) 25 | 26 | 27 | ## Table Of Contents 28 | 29 | * [Pre-requisites](#pre-requisites) 30 | * [Run Your First Test](#run-your-first-test) 31 | * [Local Testing With Robot](#testing-locally-hosted-or-privately-hosted-projects) 32 | 33 | ## Prerequisites For Running Robot Selenium Tests 34 | 35 | Before you can start performing Python automation testing using Robot, you would need to: 36 | 37 | * Install the latest Python build from the [official website](https://www.python.org/downloads/). We recommend using the latest version. 38 | * Make sure **pip** is installed in your system. You can install **pip** from [here](https://pip.pypa.io/en/stable/installation/)(use **pip3** command if you are using python3). 39 | * Download the latest **Selenium Client** and its **WebDriver bindings** from the [official website](https://www.selenium.dev/downloads/). Latest versions of **Selenium Client** and **WebDriver** are ideal for running your automation script on LambdaTest Selenium cloud grid. 40 | 41 | ### Installing Selenium Dependencies And Tutorial Repo 42 | 43 | **Step 1:** Clone the LambdaTest’s Robot-Selenium-Sample repository and navigate to the code directory as shown below: 44 | 45 | ```bash 46 | git clone https://github.com/LambdaTest/Robot-Selenium-Sample 47 | cd Robot-Selenium-Sample 48 | ``` 49 | 50 | **Step 2:** Install the [required packages](https://github.com/LambdaTest/Robot-Selenium-Sample/blob/master/requirements.txt) from the cloned project directory: 51 | 52 | ```bash 53 | pip install -r requirements.txt 54 | ``` 55 | 56 | ### Setting Up Your Authentication 57 | 58 | Make sure you have your LambdaTest credentials with you to run test automation scripts. You can get these credentials from the [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) or by your [LambdaTest Profile](https://accounts.lambdatest.com/login/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample). 59 | 60 | **Step 3:** Set LambdaTest **Username** and **Access Key** in environment variables. 61 | 62 | * For **Linux/macOS**: 63 | 64 | ```bash 65 | export LT_USERNAME="YOUR_USERNAME" 66 | export LT_ACCESS_KEY="YOUR ACCESS KEY" 67 | ``` 68 | * For **Windows**: 69 | ```bash 70 | set LT_USERNAME="YOUR_USERNAME" 71 | set LT_ACCESS_KEY="YOUR ACCESS KEY" 72 | ``` 73 | 74 | ## Run Your First Test 75 | 76 | >**Test Scenario**: Check out [common.robot](https://github.com/LambdaTest/Robot-Selenium-Sample/blob/master/Resources/Common.robot) file which tests a simple to-do application with basic functionalities like mark items as done, add items in a list, calculate total pending items etc. 77 | 78 | 79 | You can generate capabilities for your test requirements with the help of our [Desired Capability Generator](https://www.lambdatest.com/capabilities-generator/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample). 80 | 81 | ### Executing the Test 82 | 83 | **Step 4:** Please execute the command below to run your tests: 84 | ```bash 85 | make test_Windows_10_chrome_latest 86 | ``` 87 | Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on LambdaTest automation dashboard. [LambdaTest Automation Dashboard](https://automation.lambdatest.com/build/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) will help you view all your text logs, screenshots and video recording for your entire automation tests. 88 | 89 | ## Running Your Parallel Tests Using Robot 90 | 91 | To run parallel tests using TestNG, execute the below commands in the terminal: 92 | 93 | ```bash 94 | make run_all_in_parallel 95 | ``` 96 | 97 | # Testing Locally Hosted Or Privately Hosted Projects 98 | 99 | You can test your locally hosted or privately hosted projects with LambdaTest Selenium grid using LambdaTest Tunnel. All you would have to do is set up an SSH tunnel using tunnel and pass toggle `tunnel = True` via desired capabilities. LambdaTest Tunnel establishes a secure SSH protocol based tunnel that allows you in testing your locally hosted or privately hosted pages, even before they are live. 100 | 101 | Refer our [LambdaTest Tunnel documentation](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/) for more information. 102 | 103 | Here’s how you can establish LambdaTest Tunnel. 104 | 105 | Download the binary file of: 106 | * [LambdaTest Tunnel for Windows](https://downloads.lambdatest.com/tunnel/v3/windows/64bit/LT_Windows.zip) 107 | * [LambdaTest Tunnel for macOS](https://downloads.lambdatest.com/tunnel/v3/mac/64bit/LT_Mac.zip) 108 | * [LambdaTest Tunnel for Linux](https://downloads.lambdatest.com/tunnel/v3/linux/64bit/LT_Linux.zip) 109 | 110 | Open command prompt and navigate to the binary folder. 111 | 112 | Run the following command: 113 | 114 | ```bash 115 | LT -user {user’s login email} -key {user’s access key} 116 | ``` 117 | So if your user name is lambdatest@example.com and key is 123456, the command would be: 118 | 119 | ```bash 120 | LT -user lambdatest@example.com -key 123456 121 | ``` 122 | Once you are able to connect **LambdaTest Tunnel** successfully, you would just have to pass on tunnel capabilities in the code shown below : 123 | 124 | **Tunnel Capability** 125 | 126 | ```python 127 | "tunnel" = true 128 | ``` 129 | 130 | ## Documentation & Resources :books: 131 | 132 | 133 | Visit the following links to learn more about LambdaTest's features, setup and tutorials around test automation, mobile app testing, responsive testing, and manual testing. 134 | 135 | * [LambdaTest Documentation](https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) 136 | * [LambdaTest Blog](https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) 137 | * [LambdaTest Learning Hub](https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) 138 | 139 | ## LambdaTest Community :busts_in_silhouette: 140 | 141 | The [LambdaTest Community](https://community.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) allows people to interact with tech enthusiasts. Connect, ask questions, and learn from tech-savvy people. Discuss best practises in web development, testing, and DevOps with professionals from across the globe 🌎 142 | 143 | ## What's New At LambdaTest ❓ 144 | 145 | To stay updated with the latest features and product add-ons, visit [Changelog](https://changelog.lambdatest.com/) 146 | 147 | ## About LambdaTest 148 | 149 | [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) is a leading test execution and orchestration platform that is fast, reliable, scalable, and secure. It allows users to run both manual and automated testing of web and mobile apps across 3000+ different browsers, operating systems, and real device combinations. Using LambdaTest, businesses can ensure quicker developer feedback and hence achieve faster go to market. Over 500 enterprises and 1 Million + users across 130+ countries rely on LambdaTest for their testing needs. 150 | 151 | ### Features 152 | 153 | * Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments. 154 | * Real-time cross browser testing on 3000+ environments. 155 | * Test on Real device cloud 156 | * Blazing fast test automation with HyperExecute 157 | * Accelerate testing, shorten job times and get faster feedback on code changes with Test At Scale. 158 | * Smart Visual Regression Testing on cloud 159 | * 120+ third-party integrations with your favorite tool for CI/CD, Project Management, Codeless Automation, and more. 160 | * Automated Screenshot testing across multiple browsers in a single click. 161 | * Local testing of web and mobile apps. 162 | * Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems. 163 | * Geolocation testing of web and mobile apps across 53+ countries. 164 | * LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports 165 | 166 | 167 | [](https://accounts.lambdatest.com/register) 168 | 169 | 170 | 171 | ## We are here to help you :headphones: 172 | 173 | * Got a query? we are available 24x7 to help. [Contact Us](support@lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) 174 | * For more info, visit - [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=robot-selenium-sample) 175 | 176 | --------------------------------------------------------------------------------