add an after delay in browser utils functions

master
EmaMaker 2021-08-25 18:19:15 +02:00
parent 3ddccfc7b2
commit 823d8d44ce
2 changed files with 12 additions and 6 deletions

View File

@ -14,18 +14,21 @@ import time
import random
import requests
def waitForElement(browser, by, selector, timeout=5):
return WebDriverWait(browser, timeout).until(EC.element_to_be_clickable((by, selector)))
def waitForElement(browser, by, selector, timeout=5, after_delay=0):
return WebDriverWait(browser, timeout).until(EC.element_to_be_clickable((by, selector)))
def clickButton(browser, by, selector, timeout=5):
def clickButton(browser, by, selector, timeout=5, after_delay=1.5):
WebDriverWait(browser, timeout).until(EC.element_to_be_clickable((by, selector))).click()
time.sleep(1)
time.sleep(after_delay)
def inputText(browser, by, selector, text, timeout=5, interval=0.2):
def inputText(browser, by, selector, text, timeout=5, interval=0.2, after_delay=0):
element = WebDriverWait(browser, timeout).until(EC.element_to_be_clickable((by, selector)))
for i in text:
element.send_keys(i)
time.sleep(interval)
time.sleep(after_delay)
# A lifesaver: https://stackoverflow.com/questions/36141681/does-anybody-know-how-to-identify-shadow-dom-web-elements-using-selenium-webdriv
def select_shadow_element_by_css_selector(browser, selector):
@ -68,4 +71,7 @@ def start_browser(headless=False, proxy=False):
def quit_browser(driver):
driver.delete_all_cookies()
driver.quit()
driver.quit()
def delay(driver, waiting_time=5):
driver.implicitly_wait(waiting_time)