-
Notifications
You must be signed in to change notification settings - Fork 0
/
page_base.py
32 lines (25 loc) · 956 Bytes
/
page_base.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
from typing import List
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.remote.webelement import WebElement
class PageBase:
def __init__(self, driver: webdriver) -> None:
self.driver = driver
self.wait = WebDriverWait(self.driver, 10)
def wait_implicitly(self, seconds: int) -> None:
# implicit wait
self.driver.implicitly_wait(seconds)
def wait_until_visible_and_return_element(
self,
locator: tuple,
**kwargs
) -> WebElement:
# explicit wait
return self.wait.until(EC.visibility_of_element_located(locator))
def wait_until_visible_and_return_multiple_elements(
self,
locator: tuple
) -> List[WebElement]:
# explicit wait
return self.wait.until(EC.visibility_of_all_elements_located(locator))