-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09_disapperaring_elements.py
35 lines (30 loc) · 1.11 KB
/
09_disapperaring_elements.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
33
34
35
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.common.exceptions import NoSuchElementException
driver = webdriver.Firefox()
try:
wait = WebDriverWait(driver, 10)
driver.get('https://the-internet.herokuapp.com/')
link = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, "Disappearing Elements")
))
link.click()
while True:
try:
wait = WebDriverWait(driver, 10)
driver.find_element(By.PARTIAL_LINK_TEXT, 'Gallery')
except NoSuchElementException:
driver.refresh()
else:
driver.find_element(By.PARTIAL_LINK_TEXT, 'Gallery').click()
print("Succesfully clicked on ghost element")
newlink = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "h1")))
if (newlink.text == 'Not Found'):
print("Test PASS")
else:
print("Test FAIL")
break
finally:
driver.quit()