def add_environment_details_to_allure_report(): file_path = "./requirements.txt" abs_path = os.path.abspath(file_path) command = "pip install -r " + abs_path os.system(command) yield ReadConfig.write_to_report()
def setup(request): browser_name = request.param url = ReadConfig.get_url() driver = manager.start_browser(browser_name, url) if request is not None: request.node.driver = driver yield if request.node.rep_call.failed: helper.attach_screen_shot(driver, request.function.__name__) driver.quit()
def set_up(request): browser_name = request.param url = ReadConfig.get_url() factory = DriversFactory() driver = factory.get_web_driver(browser_name, url) if driver is not None: request.node.driver = driver yield if request.node.rep_call.failed: helper.attach_screen_shot(driver, request.function.__name__) driver.quit()
def create_driver(self, browser_name, url): if browser_name == "chrome": self.driver = webdriver.Chrome( executable_path=globals.CHROME_DRIVER) elif browser_name == "firefox": self.driver = webdriver.Firefox( executable_path=globals.FIREFOX_DRIVER) self.driver.maximize_window() self.driver.get(url) self.driver.implicitly_wait(ReadConfig.get_implicit_wait()) return self.driver
def start_browser(browser_name, url): driver = None if browser_name == "Chrome" or browser_name == "chrome": driver = webdriver.Chrome(executable_path=globals.CHROME_PATH) elif browser_name == "Firefox" or browser_name == "firefox": driver = webdriver.Firefox(executable_path=globals.FIREFOX_PATH) driver.implicitly_wait(ReadConfig.get_implicit_wait()) driver.maximize_window() driver.get(url) return driver
def start_browser(browser_name, url): driver = None if browser_name == "chrome" or browser_name == "Chrome": options = webdriver.ChromeOptions() options.add_argument("--start-maximized") options.add_argument("--disable-infobars") driver = webdriver.Chrome(options=options, executable_path=constants.CHROME_PATH) elif browser_name == "firefox" or browser_name == "Firefox": driver = webdriver.Firefox(executable_path=constants.FIREFOX_PATH) driver.get(url) driver.implicitly_wait(ReadConfig.get_implicit_wait()) return driver
def add_environment_details_to_allure_report(): yield ReadConfig.write_to_report()
@pytest.fixture(scope="session", autouse=True) def add_environment_details_to_allure_report(): yield ReadConfig.write_to_report() @pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_runtest_makereport(item, call): outcome = yield rep = outcome.get_result() setattr(item, "rep_" + rep.when, rep) @pytest.fixture(scope="function", params=ReadConfig.get_browser(), autouse=True) def set_up(request): browser_name = request.param url = ReadConfig.get_url() factory = DriversFactory() driver = factory.get_web_driver(browser_name, url) if driver is not None: request.node.driver = driver yield if request.node.rep_call.failed: helper.attach_screen_shot(driver, request.function.__name__) driver.quit()
def before_click(self, element, driver): wait = WebDriverWait(driver, ReadConfig.get_explicit_wait()) wait.until(ec.element_to_be_clickable(element))
def __init__(self, driver): self.driver = driver self.wait = WebDriverWait(driver, ReadConfig.get_explicit_wait()) self.driver.set_page_load_timeout(ReadConfig.get_explicit_wait()) self.action = Actions(self.driver) self.flag = False
def __int__(self, driver): self.wait = WebDriverWait(driver, ReadConfig.get_explicit_wait()) self.alert = self.wait.until(ec.alert_is_present())
def set_property(): yield ReadConfig.write_to_report()
from source.utilities.properties import ReadConfig from source.utilities import webdriver_manager as manager, helper @pytest.fixture(scope='session', autouse=True) def set_property(): yield ReadConfig.write_to_report() @pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_runtest_makereport(item, call): outcome = yield rep = outcome.get_result() setattr(item, "rep_" + rep.when, rep) @pytest.fixture(scope="function", params=[ReadConfig.get_browser()], autouse=True) def setup(request): browser_name = request.param url = ReadConfig.get_url() driver = manager.start_browser(browser_name, url) if request is not None: request.node.driver = driver yield if request.node.rep_call.failed: helper.attach_screen_shot(driver, request.function.__name__) driver.quit()
def __get_alert(driver): wait = WebDriverWait(driver, ReadConfig.get_explicit_wait()) return wait.until(ec.alert_is_present(), "Alert is not present")