-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_auth.py
28 lines (23 loc) · 1.07 KB
/
basic_auth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC # using as to rename de imported blocks
import time
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)
try:
wait = WebDriverWait(driver, 10)
driver.get('https://the-internet.herokuapp.com')
basic_auth = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, 'Basic Auth') #locating the link text to be accessed
))
basic_auth.click()
# (the driver.get stated here can be skipped if the test does not require
# to identify and click the element that is redirecting to the pop up authencication page.)
time.sleep(1)
# passing the user / pass in case of popup window that is not a HTML code and cannot be inspected.
driver.get('https://admin:[email protected]/basic_auth')
#the user / app are passed in the url as shown above.
time.sleep(1)
finally:
driver.quit()