Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BaseLocators:
- HEADER = (By.Xpath, "//div[@title='header']")
- class AuthLocators(BaseLocators):
- LOGIN_BTN = (By.ID, "login")
- class BasePage:
- def __init__(self, driver):
- self.driver = driver
- def wait(self, timeout=None):
- if timeout is None:
- timeout = 5
- return WebDriverWait(self.driver, timeout=timeout)
- def find(self, locator):
- self.wait().until(EC.presence_of_element_located(locator))
- return self.driver.find_element(*locator)
- def click(self, locator, timeout=None):
- for i in range(3):
- try:
- element = self.find(locator, timeout=timeout)
- element = self.wait(timeout).until(EC.element_to_be_clickable(locator))
- element.click()
- return
- except StaleElementReferenceException:
- if i == CLICK_RETRY - 1:
- raise
- class AuthPage(BasePage):
- locators = AuthLocators()
- def click_login(self):
- self.click(self.locators.LOGIN_BTN)
- @pytest.fixture()
- def auth_page(driver):
- return AuthPage(driver)
- def test_login(auth_page):
- auth_page.click_login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement