Example #1
0
 def open_driver(self):
     # 4 meals so do it 4 times
     options = webdriver.ChromeOptions()
     #options.add_argument('--headless')
     with NoStdStreams():
         #driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)
         driver = webdriver.PhantomJS(PhantomJsDriverManager().install())
     driver.get("https://nutrition.sa.ucsc.edu/")
     return driver
Example #2
0
def before_scenario(context, scenario):
    if 'browser' in context.config.userdata.keys():
        if context.config.userdata['browser'] is None:
            browser = 'chrome'
        else:
            browser = context.config.userdata['browser']
    else:
        browser = 'chrome'

    if browser == 'chrome':
        context.browser = webdriver.Chrome(ChromeDriverManager().install())
    elif browser == 'firefox':
        context.browser = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())
    elif browser == 'edge':
        context.browser = webdriver.Edge(EdgeDriverManager().install())
    elif browser == 'safari':
        context.browser = webdriver.Safari()
    elif browser == 'ie':
        context.browser = webdriver.Ie(IEDriverManager().install())
    elif browser == 'opera':
        context.browser = webdriver.Opera()
    elif browser == 'phantomjs':
        if 'docker' in context.config.userdata.keys():
            context.browser = webdriver.Remote(
                command_executor='http://phantomjs:8910',
                desired_capabilities=DesiredCapabilities.PHANTOMJS)
        else:
            context.browser = webdriver.PhantomJS(
                PhantomJsDriverManager().install())
    else:
        print("Browser you entered:", browser, "is invalid value")

    context.browser.implicitly_wait(WAIT)
    context.browser.maximize_window()

    context.base_url = context.config.userdata.get('instance_url')
Example #3
0
def __start_phantomjs():
    return webdriver.PhantomJS(
        executable_path=PhantomJsDriverManager().install(),
        desired_capabilities=config.desired_capabilities)
#binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
#driver = webdriver.Firefox(firefox_binary=binary, executable_path=GeckoDriverManager().install())

# Edge 15

#dir = "C:\\Users\\vchernov\\Documents\\GitHub\\automation\\indian_pytest\\Environment\\Drivers\\edgedriver.exe"
#edge_path = dir + "/MicrosoftWebDriver"
#driver = webdriver.Edge(executable_path=dir)
#driver = webdriver.Edge(EdgeDriverManager().install())

# IE11

#capabilities = DesiredCapabilities.INTERNETEXPLORER
#capabilities["platform"] = "windows"
#capabilities["browserName"] = "internet explorer"
#capabilities["ignoreProtectedModeSettings"] = True
#capabilities["IntroduceInstabilityByIgnoringProtectedModeSettings"] = True
#capabilities["nativeEvents"] = True
#capabilities["ignoreZoomSetting"] = True
#capabilities["requireWindowFocus"] = True
#capabilities["INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS"] = True
#driver = webdriver.Ie(executable_path=IEDriverManager().install())

#driver = webdriver.Ie(IEDriverManager().install())

# Phantom JS

driver = webdriver.PhantomJS(PhantomJsDriverManager().install())
driver.get("https://tproger.ru/")
driver.close()
driver.quit()
Example #5
0
def test_can_user_phantom_driver_from_cache():
    delete_old_install()
    PhantomJsDriverManager(os_type="linux").install()
    path = PhantomJsDriverManager(os_type="linux").install()
    assert path.endswith("phantomjs")
Example #6
0
def test_can_download_phantom_for_linux():
    delete_old_install()
    path = PhantomJsDriverManager(os_type="linux").install()
    assert path.endswith("phantomjs")
Example #7
0
def test_can_download_phantom_with_path():
    delete_old_install(PATH)
    path = PhantomJsDriverManager().install(PATH)
    assert os.path.exists(path)
Example #8
0
def test_can_download_phantom_for_windows():
    delete_old_install()
    path = PhantomJsDriverManager(os_type="win").install()
    assert path.endswith("phantomjs.exe")
Example #9
0
def test_can_phantom_with_selenium():
    delete_old_install()
    webdriver.PhantomJS(executable_path=PhantomJsDriverManager().install())
Example #10
0
def test_can_get_phantomjs_for_linux(os_type):
    delete_cache()
    path = PhantomJsDriverManager(os_type=os_type).install()
    assert os.path.exists(path)
Example #11
0
def test_phantomjs_manager_cached_driver_with_selenium(path):
    PhantomJsDriverManager().install(path)
    webdriver.PhantomJS(PhantomJsDriverManager().install(path))
Example #12
0
def test_phantomjs_manager_with_selenium():
    delete_old_install()
    driver_path = PhantomJsDriverManager().install()
    webdriver.PhantomJS(driver_path)
Example #13
0
def test_phantomjs_manager_with_wrong_version():
    with pytest.raises(ValueError) as ex:
        delete_old_install()
        PhantomJsDriverManager("0.2", os_type="win32").install()
    assert ex.value.args[0] == "There is no such driver phantomjs with version 0.2 " \
                               "by https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-0.2-windows.zip"
Example #14
0
def test_phantomjs_manager_with_latest_version(path):
    bin = PhantomJsDriverManager().install(path)
    assert os.path.exists(bin)
Example #15
0
def test_phantomjs_manager_with_specific_version():
    bin = PhantomJsDriverManager("2.0.0", os_type="win32").install()
    assert os.path.exists(bin)