Skip to content

Commit c0ed27c

Browse files
committed
add browser testing with selenium & edge browser tutorial
1 parent 433cc05 commit c0ed27c

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
9595
- [How to Extract YouTube Comments in Python](https://www.thepythoncode.com/article/extract-youtube-comments-in-python). ([code](web-scraping/youtube-comments-extractor))
9696
- [How to Extract All PDF Links in Python](https://www.thepythoncode.com/article/extract-pdf-links-with-python). ([code](web-scraping/pdf-url-extractor))
9797
- [How to Extract Images from PDF in Python](https://www.thepythoncode.com/article/extract-pdf-images-in-python). ([code](web-scraping/pdf-image-extractor))
98+
- [Automated Browser Testing with Edge and Selenium in Python](https://www.thepythoncode.com/article/automated-browser-testing-with-edge-and-selenium-in-python). ([code](web-scraping/selenium-edge-browser))
9899

99100
- ### [Python Standard Library](https://www.thepythoncode.com/topic/python-standard-library)
100101
- [How to Transfer Files in the Network using Sockets in Python](https://www.thepythoncode.com/article/send-receive-files-using-sockets-python). ([code](general/transfer-files/))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# [Automated Browser Testing with Edge and Selenium in Python](https://www.thepythoncode.com/article/automated-browser-testing-with-edge-and-selenium-in-python)
2+
To run this:
3+
- `pip3 install -r requirements.txt`
4+
- Run `main1.py` or `main2.py`
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# importing required package of webdriver
2+
from selenium import webdriver
3+
# Just Run this to execute the below script
4+
if __name__ == '__main__':
5+
# Instantiate the webdriver with the executable location of MS Edge web driver
6+
browser = webdriver.Edge(r"C:\Users\LenovoE14\Downloads\edgedriver\msedgedriver.exe")
7+
# Simply just open a new Edge browser and go to lambdatest.com
8+
browser.get('https://www.lambdatest.com')
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# importing required package of webdriver
2+
3+
from selenium import webdriver
4+
from selenium.webdriver.chrome.options import Options
5+
from time import sleep
6+
from selenium.webdriver.support import expected_conditions as EC
7+
from selenium.webdriver.common.by import By
8+
from selenium.common.exceptions import TimeoutException
9+
from selenium.webdriver.support.ui import WebDriverWait
10+
from selenium.webdriver.opera.options import Options
11+
# Just Run this main.py to execute the below script
12+
from selenium.webdriver.support.wait import WebDriverWait
13+
14+
if __name__ == '__main__':
15+
# Instantiate the webdriver with the executable location of MS Edge
16+
browser = webdriver.Edge(r"C:\Users\LenovoE14\Downloads\edgedriver\msedgedriver.exe")
17+
# Simply just open a new Edge browser and go to lambdatest.com
18+
browser.maximize_window()
19+
browser.get('https://www.lambdatest.com')
20+
21+
try:
22+
# Get the text box to insert Email using selector ID
23+
myElem_1 = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'useremail')))
24+
# Entering the email address
25+
myElem_1.send_keys("rishabhps@lambdatest.com")
26+
myElem_1.click()
27+
# Get the Submit button to click and start free testing using selector CSS_SELECTOR
28+
myElem_2 = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#testing_form > div")))
29+
# Starting free testing on LambdaTest
30+
myElem_2.click()
31+
sleep(10)
32+
except TimeoutException:
33+
print("No element found")
34+
35+
sleep(10)
36+
37+
browser.close()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
selenium==3.141
2+
msedge-selenium-tools

0 commit comments

Comments
 (0)