https://github.com/lambdatest/unittest-tunnel
How to start tunnel for automation test in UnitTest on LambdaTest
https://github.com/lambdatest/unittest-tunnel
lambdatest selenium testing unittest
Last synced: about 2 months ago
JSON representation
How to start tunnel for automation test in UnitTest on LambdaTest
- Host: GitHub
- URL: https://github.com/lambdatest/unittest-tunnel
- Owner: LambdaTest
- Created: 2022-06-10T19:30:17.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-10T20:06:17.000Z (about 4 years ago)
- Last Synced: 2025-06-01T05:11:05.788Z (about 1 year ago)
- Topics: lambdatest, selenium, testing, unittest
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to start tunnel for automation test in UnitTest on [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=UnitTest-tunnel)
If you want to run your an automation test in Pytest on LambdaTest using the tunnel and want to start the tunnel automatically in the script, you can use the follwing steps. You can refer to sample test repo [here](https://github.com/LambdaTest/Python-UnitTest-Selenium).
## Steps
### Step 1: Download the LT tunnel binary from LT Dashboard
Go to your LambdaTest dashboard and click the configure tunnel button on the top right corner and use the download link to download the binary file.
### Step 2: Code to run LT tunnel before test
The tunnel should be started before test case execution and end after completion. To achieve this, tunnel can be started in the main function like so:
```python
import subprocess
if __name__ == "__main__":
#start tunnel process
tunnel_process = subprocess.Popen(["./LT","--user",username,"--key",access_key],stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
#run testcases
unittest.main()
#end tunnel
tunnel_process.terminate()
```
### Step 3: Set tunnel capability to True
Add the `"tunnel": True` capability in your test file:
```python
desired_caps = {
'LT:Options': {
"build": "Python Demo", # Change your build name here
"name": "Python Demo Test", # Change your test name here
"platformName": "Windows 11",
"selenium_version": "4.0.0",
"tunnel": True
},
"browserName": "Chrome",
"browserVersion": "98.0",
}
```
### Step 4: Run your test
```bash
python lambdatest_test.py
```
# Links:
[LambdaTest Community](http://community.lambdatest.com/)