-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclick_functions.py
More file actions
28 lines (24 loc) · 1.03 KB
/
click_functions.py
File metadata and controls
28 lines (24 loc) · 1.03 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
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium import webdriver
def click_something(xpath, driver):
try:
WebDriverWait(driver, 2).until(EC.element_to_be_clickable((By.XPATH, xpath))).click()
except KeyboardInterrupt:
quit()
except:
last_height = driver.execute_script("return document.body.scrollHeight")
cur_height = driver.execute_script("return window.scrollY")
if last_height > cur_height + 300:
driver.execute_script("window.scrollTo(0, window.scrollY + 300)")
print("could not find element:" + xpath)
click_something(xpath, driver)
else:
quit()
def click_dropdown(value, driver):
xpath = "//div[contains(text(), '" + value + "')]"
click_something(xpath, driver)
def click_checkbox(value, driver):
xpath = "//label[contains(text(), '" + value + "')]"
click_something(xpath, driver)