コード例 #1
0
def driver(request):
    """Launching webdriver"""
    browser_name = request.config.getoption("--browser")
    print(browser_name)
    if browser_name == 'firefox':
        capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()
        capabilities['timeouts'] = {
            'implicit': 300000,
            'pageLoad': 300000,
            'script': 30000
        }
        capabilities['loggingPrefs'] = {
            'browser': 'ALL',
            'client': 'ALL',
            'driver': 'ALL',
            'performance': 'ALL',
            'server': 'ALL'
        }
        profile = webdriver.FirefoxProfile()
        profile.set_preference('app.update.auto', False)
        profile.set_preference('app.update.enabled', False)
        profile.accept_untrusted_certs = True
        wd = EventFiringWebDriver(
            webdriver.Firefox(firefox_profile=profile,
                              capabilities=capabilities), TestListenerDB())
        wd.maximize_window()
    elif browser_name == 'chrome':
        capabilities = webdriver.DesiredCapabilities.CHROME.copy()
        capabilities['acceptSslCerts'] = True
        capabilities['acceptInsecureCerts'] = True
        capabilities['goog:loggingPrefs'] = {'performance': 'ALL'}
        # chrome_options = Options()
        # chrome_options.add_experimental_option('w3c', False)
        wd = EventFiringWebDriver(
            webdriver.Chrome(desired_capabilities=capabilities),
            TestListenerDB())
        wd.fullscreen_window()
    else:
        print('Unsupported browser!')
        sys.exit(1)
    wd.implicitly_wait((request.config.getoption("--iwait")))
    wd.set_page_load_timeout((request.config.getoption("--pltimeout")))
    implicitly_wait = request.config.getoption("--iwait")
    page_load_timeout = request.config.getoption("--pltimeout")
    print(implicitly_wait)
    print(page_load_timeout)
    yield wd
    wd.quit()
コード例 #2
0
ファイル: conftest.py プロジェクト: Kyanty/qa_automation
def driver(request):
    wait = request.config.getoption("--wait")
    browser = request.config.getoption("--browser")
    if browser == 'firefox':
        capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()
        capabilities['timeouts'] = {
            'implicit': int(wait),
            'pageLoad': int(wait)
        }
        capabilities['loggingPrefs'] = {
            'browser': 'ALL',
            'client': 'ALL',
            'driver': 'ALL',
            'performance': 'ALL',
            'server': 'ALL'
        }
        profile = webdriver.FirefoxProfile()
        profile.set_preference('app.update.auto', False)
        profile.set_preference('app.update.enabled', False)
        profile.accept_untrusted_certs = True
        wd = EventFiringWebDriver(
            webdriver.Firefox(firefox_profile=profile,
                              capabilities=capabilities), MyListener())
        wd.maximize_window()
    elif browser == 'chrome':
        capabilities = webdriver.DesiredCapabilities.CHROME.copy()
        capabilities['timeouts'] = {
            'implicit': int(wait),
            'pageLoad': int(wait)
        }
        capabilities['acceptSslCerts'] = True
        capabilities['acceptInsecureCerts'] = True
        wd = webdriver.Chrome(desired_capabilities=capabilities)
        wd.fullscreen_window()
    else:
        print('Unsupported browser!')
        sys.exit(1)
    yield wd
    wd.quit()