This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import logging | |
from selenium import webdriver | |
from selenium.webdriver.support.ui import WebDriverWait | |
import pytest | |
import sys | |
# If you want more logging in the test code, export TEST_LOG_LEVEL=DEBUG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium.webdriver.support.ui import WebDriverWait | |
import pages | |
def test_login_with_invalid_credentials(login_url): | |
try: | |
driver = get_browser() | |
driver.get(login_url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .Base import BasePage | |
from locators import LoginPageLocators as Locators | |
from elements import InputPageElement, PageElement | |
class LoginPage(BasePage): | |
""" Contains methods to do things on the login page """ | |
username = InputPageElement(Locators.USERNAME) | |
password = InputPageElement(Locators.PASSWORD) | |
error_message = PageElement(Locators.LOGIN_ERROR_MESSAGE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoginPageLocators(object): | |
""" A class for login page locators. """ | |
USERNAME = (By.XPATH, '//input[@data-test-id="login-username"]') | |
PASSWORD = (By.XPATH, '//input[@data-test-id="login-password"]') | |
LOGIN_BUTTON = (By.XPATH, '//button[@data-test-id="login-button"]') | |
LOGIN_ERROR_MESSAGE = (By.XPATH, '//div[@data-test-id="login-error"]') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BasePageElement(object): | |
"""Base page class that is initialized on every page object class.""" | |
def __init__(self, locator:Tuple[str, str]): | |
self.locator = locator | |
def __set__(self, instance, value:str): | |
""" returns the element so that derived classes can set things based upon the type of element they are dealing with """ | |
driver = instance.driver | |
WebDriverWait(driver, 10).until( | |
lambda driver: driver.find_element(*self.locator)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium.webdriver.support.ui import WebDriverWait | |
class BasePageElement(object): | |
"""Base page class that is initialized on every page object class.""" | |
def __set__(self, obj, value): | |
"""Sets the text to the value supplied""" | |
driver = obj.driver | |
WebDriverWait(driver, 100).until( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium.webdriver.support.ui import WebDriverWait | |
class BasePageElement(object): | |
"""Base page class that is initialized on every page object class.""" | |
def __set__(self, obj, value): | |
"""Sets the text to the value supplied""" | |
driver = obj.driver | |
WebDriverWait(driver, 100).until( |