-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path36_redirect_link.py
96 lines (79 loc) · 2.93 KB
/
36_redirect_link.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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 time import sleep
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, "Redirect Link")
))
link.click()
redirection = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, "here")
))
redirection.click()
get_url = driver.current_url
if (get_url == 'https://the-internet.herokuapp.com/status_codes'):
full_codes = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, "here")
))
full_codes.click()
sleep(1)
get_url = driver.current_url
if (get_url == 'http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml'):
print('test PASS. Sucessfully followed link')
driver.back()
else:
print('Test FAIL. Unable to follow aaaaaa link')
driver.back()
code200 = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, "200")
))
code200.click()
get_url = driver.current_url
if (get_url == 'https://the-internet.herokuapp.com/status_codes/200'):
print('Test PASS. Sucessfully followed link')
driver.back()
else:
print('Test FAIL. Unable to follow a link')
driver.back()
code301 = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, "301")
))
code301.click()
get_url = driver.current_url
if (get_url == 'https://the-internet.herokuapp.com/status_codes/301'):
print('Test PASS. Sucessfully followed link')
driver.back()
else:
print('Test FAIL. Unable to follow a link')
driver.back()
code404 = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, "404")
))
code404.click()
get_url = driver.current_url
if (get_url == 'https://the-internet.herokuapp.com/status_codes/404'):
print('Test PASS. Sucessfully followed link')
driver.back()
else:
print('Test FAIL. Unable to follow a link')
driver.back()
code500 = wait.until(EC.presence_of_element_located(
(By.LINK_TEXT, "500")
))
code500.click()
get_url = driver.current_url
if (get_url == 'https://the-internet.herokuapp.com/status_codes/500'):
print('Test PASS. Sucessfully followed link')
driver.back()
else:
print('Test FAIL. Unable to follow a link')
driver.back()
else:
print('Test FAIL. Unable to follow a link')
finally:
driver.quit()