-
Notifications
You must be signed in to change notification settings - Fork 0
/
08_digest_aut.py
32 lines (27 loc) · 1.1 KB
/
08_digest_aut.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
29
30
31
32
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
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.alert import Alert
driver = webdriver.Chrome()
try:
wait = WebDriverWait(driver, 10)
driver.get('https://the-internet.herokuapp.com/')
digest_link = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, "Digest Authentication")
))
digest_link.click()
#??????
wait.until(EC.alert_is_present())
alert = driver.switch_to.alert
alert.send_keys('admin' + Keys.TAB + 'admin')
#driver.execute_script("driver.switchTo().alert().sendKeys('admin' + Keys.TAB + 'admin');")
p = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'p')))
if (p.text == 'Congratulations! You must have the proper credentials.'):
print('test PASS. U saccesfully logged in')
else:
print("Test FAIL.Unable to log in")
finally:
driver.quit()