Skip to content

Commit a138ce2

Browse files
committed
Readme+todotask
1 parent e8661dc commit a138ce2

File tree

3 files changed

+115
-96
lines changed

3 files changed

+115
-96
lines changed

README.md

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,66 @@
1-
## Python unittest automation Lambdatest
1+
# Python-Pytest-Selenium
22

3-
Python selenium automation sample test for [LambdaTest](https://www.lambdatest.com/) cloud-based Selenium Grid.
3+
![MSTest](https://opengraph.githubassets.com/8039186e9aebcc17be88d53ac4b85364a56f6aae503057e0ebf36dfcc5b5cc32/LambdaTest/python-selenium-sample)
44

5+
## Prerequisites
56

6-
## Install Python
7-
- Download the latest python build from https://www.python.org/downloads/
8-
- Make sure pip should installed. you can check using `pip --version`
7+
1. Install pip and python.
98

9+
```
10+
sudo apt install python-pip
11+
sudo apt install python
12+
```
13+
14+
2. The recommended way to run your tests would be in virtualenv. It will isolate the build from other setups you may have running and ensure that the tests run with the specified versions of the modules specified in the requirements.txt file.
15+
16+
```
17+
pip install virtualenv
18+
```
19+
20+
## Steps to Run your First Test
21+
22+
Step 1. Clone the Python-Selenium-Sample Repository.
23+
24+
```
25+
git clone https://github.com/LambdaTest/python-selenium-sample
26+
```
27+
28+
Step 2. Next we create and Activate the virtual environment in the Python-Selenium-Sample folder.
29+
30+
```
31+
virtualenv venv
32+
source venv/bin/activate
33+
```
1034

11-
### Configuring Test
12-
- Replace {username} with your username
13-
- Replace {accessToken} with your username
14-
- List of supported platfrom, browser, version can be found at https://www.lambdatest.com/capabilities-generator/
35+
Step 3. Then install required packages.
1536

37+
```
38+
pip install -r requirements.txt
39+
```
1640

17-
### Installating Dependencies
18-
```bash
19-
pip install selenium
20-
export PYTHONWARNINGS="ignore:Unverified HTTPS request" //Disable ssl warning
41+
Step 4. Inside Python-Selenium-Sample folder, export the Lambda-test Credentials. You can get these from your automation dashboard.
42+
43+
<p align="center">
44+
<b>For Linux/macOS:</b>
45+
46+
```
47+
export LT_USERNAME="YOUR_USERNAME"
48+
export LT_ACCESS_KEY="YOUR ACCESS KEY"
49+
```
50+
<p align="center">
51+
<b>For Windows:</b>
2152
```
2253
23-
### Executing Test
24-
```bash
25-
python google-search-lambdatest.py
54+
set LT_USERNAME="YOUR_USERNAME"
55+
set LT_ACCESS_KEY="YOUR ACCESS KEY"
2656
```
57+
58+
Step 5. To run your first test.
59+
60+
```
61+
python lambdatest.py
62+
```
63+
2764
## About LambdaTest
28-
[LambdaTest](https://www.lambdatest.com/) is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your [selenium automation testing](https://www.lambdatest.com/selenium-automation) to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel.
65+
66+
[LambdaTest](https://www.lambdatest.com/) is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your [selenium automation testing](https://www.lambdatest.com/selenium-automation) to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel.

google-search-lambdatest.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

lambdatest.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import unittest
2+
import sys
3+
from selenium import webdriver
4+
5+
username = "firdausia" # Replace the username
6+
access_key = "U9X9M7Ck8lClEDPqyF87KOERu4uwbIjoOXBPxj9ThLfGHc9gA5" # Replace the access key
7+
8+
class FirstSampleTest(unittest.TestCase):
9+
# Generate capabilites from here: https://www.lambdatest.com/capabilities-generator/
10+
# setUp runs before each test case and
11+
def setUp(self):
12+
desired_caps = {
13+
"build": 'PyunitTest sample build', # Change your build name here
14+
"name": 'Py-unittest', # Change your test name here
15+
"browserName": 'Chrome',
16+
"version": '92.0',
17+
"platform": 'Windows 10',
18+
"resolution": '1024x768',
19+
"console": 'true', # Enable or disable console logs
20+
"network":'true' # Enable or disable network logs
21+
}
22+
self.driver = webdriver.Remote(
23+
command_executor="https://{}:{}@hub.lambdatest.com/wd/hub".format(username, access_key),
24+
desired_capabilities= desired_caps)
25+
26+
27+
# tearDown runs after each test case
28+
def tearDown(self):
29+
self.driver.quit()
30+
31+
# """ You can write the test cases here """
32+
def test_unit_user_should_able_to_add_item(self):
33+
# try:
34+
driver = self.driver
35+
36+
# Url
37+
driver.get("https://lambdatest.github.io/sample-todo-app/")
38+
39+
# Click on check box
40+
check_box_one = driver.find_element_by_name("li1")
41+
check_box_one.click()
42+
43+
# Click on check box
44+
check_box_two = driver.find_element_by_name("li2")
45+
check_box_two.click()
46+
47+
# Enter item in textfield
48+
textfield = driver.find_element_by_id("sampletodotext")
49+
textfield.send_keys("Yey, Let's add it to list")
50+
51+
# Click on add button
52+
add_button = driver.find_element_by_id("addbutton")
53+
add_button.click()
54+
55+
# Verified added item
56+
added_item = driver.find_element_by_xpath("//span[@class='done-false']").text
57+
print (added_item)
58+
59+
if __name__ == "__main__":
60+
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy