Skip to content

Commit 1bea62d

Browse files
authored
Merge pull request #5 from salmanlt/patch-1
UPdated Python Readme
2 parents b832295 + 6b1d9c7 commit 1bea62d

File tree

1 file changed

+188
-37
lines changed

1 file changed

+188
-37
lines changed

README.md

Lines changed: 188 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,217 @@
1-
# Python-Selenium-Sample
1+
# Run Selenium Tests With Python On LambdaTest
22

3-
![MSTest](https://opengraph.githubassets.com/8039186e9aebcc17be88d53ac4b85364a56f6aae503057e0ebf36dfcc5b5cc32/LambdaTest/python-selenium-sample)
3+
![171934563-4806efd2-1154-494c-a01d-1def95657383 (1)](https://user-images.githubusercontent.com/70570645/172273386-fa9606ac-3e63-4b2e-8978-3142add3e038.png)
4+
5+
6+
<p align="center">
7+
<a href="https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample" target="_bank">Blog</a>
8+
&nbsp; &#8901; &nbsp;
9+
<a href="https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample" target="_bank">Docs</a>
10+
&nbsp; &#8901; &nbsp;
11+
<a href="https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample" target="_bank">Learning Hub</a>
12+
&nbsp; &#8901; &nbsp;
13+
<a href="https://www.lambdatest.com/newsletter/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample" target="_bank">Newsletter</a>
14+
&nbsp; &#8901; &nbsp;
15+
<a href="https://www.lambdatest.com/certifications/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample" target="_bank">Certifications</a>
16+
&nbsp; &#8901; &nbsp;
17+
<a href="https://www.youtube.com/c/LambdaTest" target="_bank">YouTube</a>
18+
</p>
19+
&emsp;
20+
&emsp;
21+
&emsp;
22+
23+
*Learn how to run your Python automation testing scripts on the LambdaTest platform*
24+
25+
[<img height="58" width="200" src="https://user-images.githubusercontent.com/70570645/171866795-52c11b49-0728-4229-b073-4b704209ddde.png">](https://accounts.lambdatest.com/register)
26+
27+
28+
## Table Of Contents
29+
30+
* [Pre-requisites](#pre-requisites)
31+
* [Run Your First Test](#run-your-first-test)
32+
* [Local Testing With Python](#testing-locally-hosted-or-privately-hosted-projects)
433

534
## Prerequisites
635

7-
1. Install pip and python.
36+
Before you can start performing **Python** automation testing with **Selenium**, you would need to:
837

9-
```
10-
sudo apt install python-pip
11-
sudo apt install python
12-
```
38+
* Install the latest Python build from the [official website](https://www.python.org/downloads/). We recommend using the latest version.
39+
* Make sure **pip** is installed in your system. You can install **pip** from [here](https://pip.pypa.io/en/stable/installation/).
40+
* 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.
41+
42+
### Installing Selenium Dependencies And Tutorial Repo
1343

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.
44+
**Step 1:** Clone the LambdaTest’s python-selenium-sample repository and navigate to the code directory as shown below:
1545

46+
```bash
47+
git clone https://github.com/LambdaTest/python-selenium-sample
48+
cd python-selenium-sample
1649
```
17-
pip install virtualenv
50+
51+
**Step 2:** Download the driver from the link, or you can use **pip** to install it.
52+
```bash
53+
pip install selenium
54+
export PYTHONWARNINGS="ignore:Unverified HTTPS request" //Disable ssl warning
1855
```
1956

20-
## Steps to Run your First Test
57+
### Setting Up Your Authentication
2158

22-
Step 1. Clone the Python-Selenium-Sample Repository.
59+
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) or by your [LambdaTest Profile](https://accounts.lambdatest.com/login).
2360

24-
```
25-
git clone https://github.com/LambdaTest/python-selenium-sample
26-
```
61+
**Step 2:** Set LambdaTest **Username** and **Access Key** in environment variables.
2762

28-
Step 2. Next we create and Activate the virtual environment in the Python-Selenium-Sample folder.
63+
* For **Linux/macOS**:
64+
65+
```bash
66+
export LT_USERNAME="YOUR_USERNAME"
67+
export LT_ACCESS_KEY="YOUR ACCESS KEY"
68+
```
69+
* For **Windows**:
70+
```bash
71+
set LT_USERNAME="YOUR_USERNAME"
72+
set LT_ACCESS_KEY="YOUR ACCESS KEY"
73+
```
2974

30-
```
31-
virtualenv venv
32-
source venv/bin/activate
33-
```
75+
## Run Your First Test
3476

35-
Step 3. Then install required packages.
77+
>**Test Scenario**: The [lambdatest.py](https://github.com/LambdaTest/python-selenium-sample/blob/master/lambdatest.py) sample script tests a simple to-do application with basic functionalities like mark items as done, add items in a list, calculate total pending items etc.
3678
37-
```
38-
pip install -r requirements.txt
39-
```
79+
### Configuration Of Your Test Capabilities
4080

41-
Step 4. Inside Python-Selenium-Sample folder, export the Lambda-test Credentials. You can get these from your automation dashboard.
81+
**Step 4:** In the python script, you need to update your test capabilities. In this code, we are passing browser, browser version, and operating system information, along with LambdaTest Selenium grid capabilities via capabilities object.
4282

43-
<p align="center">
44-
<b>For Linux/macOS:</b>
45-
83+
The capabilities object in the above code are defined as:
84+
85+
```python
86+
capabilities = {
87+
"build": "your build name",
88+
"name": "your test name",
89+
"platformName": "Windows 10"
90+
"browserName": "Chrome",
91+
"browserVersion": "latest",
92+
}
4693
```
47-
export LT_USERNAME="YOUR_USERNAME"
48-
export LT_ACCESS_KEY="YOUR ACCESS KEY"
94+
You can generate capabilities for your test requirements with the help of our inbuilt [Desired Capability Generator](https://www.lambdatest.com/capabilities-generator/).
95+
96+
### Executing The Test
97+
98+
**Step 5:** You would need to execute the below command in your terminal/cmd.
99+
100+
```bash
101+
python google-search-lambdatest.py
49102
```
103+
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.
50104

51-
<p align="center">
52-
<b>For Windows:</b>
53-
105+
106+
## Testing Locally Hosted Or Privately Hosted Projects
107+
108+
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.
109+
110+
Refer our [LambdaTest Tunnel documentation](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/) for more information.
111+
112+
Here’s how you can establish LambdaTest Tunnel.
113+
114+
Download the binary file of:
115+
* [LambdaTest Tunnel for Windows](https://downloads.lambdatest.com/tunnel/v3/windows/64bit/LT_Windows.zip)
116+
* [LambdaTest Tunnel for macOS](https://downloads.lambdatest.com/tunnel/v3/mac/64bit/LT_Mac.zip)
117+
* [LambdaTest Tunnel for Linux](https://downloads.lambdatest.com/tunnel/v3/linux/64bit/LT_Linux.zip)
118+
119+
Open command prompt and navigate to the binary folder.
120+
121+
Run the following command:
122+
123+
```bash
124+
LT -user {user’s login email} -key {user’s access key}
54125
```
55-
set LT_USERNAME="YOUR_USERNAME"
56-
set LT_ACCESS_KEY="YOUR ACCESS KEY"
126+
So if your user name is lambdatest@example.com and key is 123456, the command would be:
127+
128+
```bash
129+
LT -user lambdatest@example.com -key 123456
57130
```
131+
Once you are able to connect **LambdaTest Tunnel** successfully, you would just have to pass on tunnel capabilities in the code shown below :
132+
133+
**Tunnel Capability**
58134

59-
Step 5. To run your first test.
60135
```
61-
python lambdatest.py
136+
"tunnel" : true
62137
```
63138

139+
## Tutorials 📙
140+
141+
Check out our latest tutorials on Python automation testing 👇
142+
143+
* [Why Python Is A Preferred Language For Test Automation?](https://www.lambdatest.com/blog/python-automation-testing/)
144+
* [7 Best Python Testing Frameworks](https://www.lambdatest.com/blog/top-python-frameworks-in-2020-for-selenium-test-automation/)
145+
* [Selenium 4 With Python: All You Need To Know](https://www.lambdatest.com/blog/selenium-with-python/)
146+
* [How to Set Up Selenium With Python for Modern Web Automation](https://www.lambdatest.com/blog/selenium-webdriver-with-python/)
147+
* [Using Selenium and Python Hypothesis for Automation Testing](https://www.lambdatest.com/blog/using-selenium-and-python-hypothesis-for-automation-testing/)
148+
* [Selenium Python Tutorial: Getting Started With BDD In Behave](https://www.lambdatest.com/blog/selenium-python-behave-tutorial-bdd/)
149+
* [Selenium Python Tutorial: Getting Started With Pytest](https://www.lambdatest.com/blog/selenium-python-pytest-testing-tutorial/)
150+
* [Selenium Python Tutorial: Running First PyUnit Script](https://www.lambdatest.com/blog/using-pyunit-for-testing-a-selenium-python-test-suite/)
151+
* [Robot Framework with Selenium and Python](https://www.lambdatest.com/blog/robot-framework-tutorial/)
152+
* [Getting Started With Selenium Python [Tutorial]](https://www.lambdatest.com/blog/robot-framework-tutorial/)
153+
* [Running Python Selenium Test in Parallel With PyTest](https://www.lambdatest.com/blog/robot-framework-tutorial/)
154+
* [Parallel Testing In Selenium WebDriver With Python Using Unittest](https://www.lambdatest.com/blog/robot-framework-tutorial/)
155+
* [Automated Browser Testing with Opera and Selenium in Python](https://www.lambdatest.com/blog/automated-browser-testing-with-opera-and-selenium-in-python/)
156+
* [How To Take A Screenshot Using Python & Selenium?](https://www.lambdatest.com/blog/python-selenium-screenshots/)
157+
* [How To Drag And Drop In Selenium With Python?](https://www.lambdatest.com/blog/drag-and-drop-in-selenium-python/)
158+
* [How To Switch Tabs In A Browser Using Selenium Python?](https://www.lambdatest.com/blog/python-selenium-switch-tabs/)
159+
* [How To Get Page Source In Selenium Using Python?](https://www.lambdatest.com/blog/how-to-get-page-source-in-selenium-webdriver/)
160+
* [How To Handle Dropdowns In Selenium WebDriver Using [Python?]](https://www.lambdatest.com/blog/handling-dropdown-in-selenium-webdriver-python/)
161+
* [How To Do Parameterization In Pytest With Selenium?](https://www.lambdatest.com/blog/parameterization-in-pytest-with-selenium/)
162+
* [Page Object Model (POM) In Selenium Python](https://www.lambdatest.com/blog/page-object-model-in-selenium-python/)
163+
* [How To Read Configuration Files in Python Using Selenium](https://www.lambdatest.com/blog/how-to-read-configuration-files-in-python-using-selenium/)
164+
* [How To Create an Automated Web Bot With Selenium in Python?](https://www.lambdatest.com/blog/automated-web-bot-with-selenium-python/)
165+
* [How To Perform Web Scraping Using Selenium and Python?](https://www.lambdatest.com/blog/web-scraping-using-selenium-and-python/)
166+
* [Adding Firefox Extensions With Selenium in Python](https://www.lambdatest.com/blog/adding-firefox-extensions-with-selenium-in-python/)
167+
* [How to Handle JavaScript Alert in Selenium WebDriver Using Python?](https://www.lambdatest.com/blog/how-to-handle-javascript-alert-in-selenium-webdriver/)
168+
* [Use Selenium Wait for Page to Load With Python](https://www.lambdatest.com/blog/selenium-wait-for-page-to-load/)
169+
* [Selenium Python Cheat Sheet for Test Automation](https://www.lambdatest.com/blog/selenium-python-cheat-sheet/)
170+
171+
172+
## Documentation & Resources :books:
173+
174+
175+
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.
176+
177+
* [LambdaTest Documentation](https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample)
178+
* [LambdaTest Blog](https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample)
179+
* [LambdaTest Learning Hub](https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample)
180+
181+
## LambdaTest Community :busts_in_silhouette:
182+
183+
The [LambdaTest Community](https://community.lambdatest.com/) 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 🌎
184+
185+
## What's New At LambdaTest ❓
186+
187+
To stay updated with the latest features and product add-ons, visit [Changelog](https://changelog.lambdatest.com/)
188+
64189
## About LambdaTest
65190

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.
191+
[LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=python-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.
192+
193+
### Features
194+
195+
* Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments.
196+
* Real-time cross browser testing on 3000+ environments.
197+
* Test on Real device cloud
198+
* Blazing fast test automation with HyperExecute
199+
* Accelerate testing, shorten job times and get faster feedback on code changes with Test At Scale.
200+
* Smart Visual Regression Testing on cloud
201+
* 120+ third-party integrations with your favorite tool for CI/CD, Project Management, Codeless Automation, and more.
202+
* Automated Screenshot testing across multiple browsers in a single click.
203+
* Local testing of web and mobile apps.
204+
* Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems.
205+
* Geolocation testing of web and mobile apps across 53+ countries.
206+
* LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports
207+
208+
209+
[<img height="58" width="200" src="https://user-images.githubusercontent.com/70570645/171866795-52c11b49-0728-4229-b073-4b704209ddde.png">](https://accounts.lambdatest.com/register)
210+
211+
212+
213+
## We are here to help you :headphones:
214+
215+
* Got a query? we are available 24x7 to help. [Contact Us](support@lambdatest.com)
216+
* For more info, visit - [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=python-selenium-sample)
217+

0 commit comments

Comments
 (0)