forked from jobeasy-team/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_script.py
More file actions
executable file
·30 lines (23 loc) · 850 Bytes
/
Copy pathsample_script.py
File metadata and controls
executable file
·30 lines (23 loc) · 850 Bytes
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
from time import sleep
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
# init driver
driver = webdriver.Chrome()
# driver.implicitly_wait(10)
driver.maximize_window()
# open the url
driver.get('https://www.google.com/')
search = driver.find_element(By.NAME, 'q')
search.clear()
search.send_keys('Dress')
# wait for 4 sec
driver.wait = WebDriverWait(driver, 10)
driver.wait.until(EC.element_to_be_clickable((By.NAME, 'btnK')))
# click search
driver.find_element(By.NAME, 'btnK').click()
# verify
assert 'Dress' in driver.find_element(By.XPATH, "//div[contains(@class,'commercial-unit-desktop-top')]").text
assert 'Dress' in driver.find_element(By.XPATH, "//div[@class='g']").text
driver.quit()