-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTask1.py
More file actions
53 lines (43 loc) · 1.43 KB
/
Task1.py
File metadata and controls
53 lines (43 loc) · 1.43 KB
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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Chrome("C:\\Program Files (x86)\\chromedriver.exe")
#hi
driver.get("https://techwithtim.net")
print(driver.title)
search = driver.find_element(By.NAME,"s")
driver.get("https://techwithtim.net")
driver.set_page_load_timeout(10)
driver.maximize_window()
driver.implicitly_wait(10)
x = driver.execute_script("return document.readyState")
if x == "complete":
assert True
else:
assert False
print(driver.title)
search = driver.find_element(By.NAME, "s")
search.send_keys("test")
search.send_keys(Keys.RETURN)
try:
main = WebDriverWait(driver,10).until(
EC.presence_of_element_located((By.ID, "main"))
)
articals = main.find_elements(By.TAG_NAME,"article")
for articale in articals:
header = articale.find_element(By.CLASS_NAME ,"entery-summary")
print(header.text)
finally:
driver.quit()
main = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "main"))
)
articals = main.find_elements(By.TAG_NAME, "article")
for articale in articals:
header = articale.find_element(By.CLASS_NAME, "entery-summary")
print(header.text)
finally:
driver.quit()