def edge(browser):
    """
    Opens Edge browsers and makes a screenshot of the desired website.
    :param browser: Browser
    :return: None
    """
    edge_driver = prepare_driver()
    driver = edge_driver.create_edge_driver()
    try:
        open_browser(driver, browser.url)
        screenshot_website(driver, browser, ie=True)
    finally:
        logger.info("Closing the browsers.")
        driver.quit()
Beispiel #2
0
def open_opera(driver, browser, old_driver=False):
    """
    Run screenshot in different thread.
    :param driver: Driver
    :param browser: Browser
    :param old_driver: True if opera runs old driver, False otherwise
    :return: None
    """
    try:
        if old_driver:
            logger.info("Starting timeout_and_screenshot.")
            timeout_and_screenshot(driver, browser)
        else:
            open_browser(driver, browser.url)
            screenshot_website(driver, browser)
    except Exception as e:
        logger.error("Error in open_opera: {}".format(e))
Beispiel #3
0
def open_chromium(driver, browser, old_driver=False):
    """
    Opens Chromium and makes a screenshot of the desired website. If the driver version is older,
    it sets a timeout for the script to finish.
    :param driver: Browser driver
    :param browser: Browser
    :param old_driver: True if the driver version is older than 74
    :return: None
    """
    try:
        if old_driver:
            open_browser_with_timeout(driver, browser)
        else:
            open_browser(driver, browser.url)
            screenshot_website(driver, browser)
    except Exception as e:
        logger.error("Error in open_chromium: {}".format(e))
Beispiel #4
0
def open_browser_with_timeout(driver, browser):
    """
    Opens Chromium, sets a timeout for the script to finish and takes a screenshot
    :param driver: Browser driver
    :param browser: Browser
    :return: None
    """
    try:
        if browser.case == "expired" or browser.case == "wrong-host" or browser.case == "self-signed" \
                or browser.case == "untrusted-root" or browser.case == "revoked":
            driver.set_page_load_timeout(5)
            driver.set_script_timeout(5)
        open_browser(driver, browser.url)
        screenshot_website(driver, browser)
    except Exception as e:
        logger.error("Exception occured {} - making screenshot.".format(e))
        screenshot_website(driver, browser)
Beispiel #5
0
def firefox(browser):
    """
    Opens Firefox and makes a screenshot of the desired website.
    :param browser: Browser
    :return: None
    """
    browser.set_short_browser_version()
    ff_driver = prepare_driver(browser)
    driver = ff_driver.create_firefox_driver()
    try:
        open_browser(driver, browser.url)
        screenshot_website(driver, browser)
    except WebDriverException as e:
        logger.error(
            "Exception from Selenium but going to take a screenshot. -- {}".
            format(e))
        screenshot_website(driver, browser)
    finally:
        driver.quit()
    kill_browser()