Exemplo n.º 1
0
def browser(request):
    browser_type = request.config.getoption('--browser')
    if browser_type == 'chrome':
        cdm = ChromeDriverManager()
        cdm.download_and_install()
        option = ChromeOptions()
        option.add_argument('--kiosk')
        # option.add_argument('--disable-popup-blocking')
        option.add_argument('--ignore-certificate-errors')
        # option.headless = True
        browser = webdriver.Chrome(options=option)
        # browser.implicitly_wait(5)
        request.addfinalizer(browser.quit)
        return browser
    if browser_type == 'firefox':
        gdm = GeckoDriverManager()
        gdm.download_and_install()
        option = FirefoxOptions()
        option.add_argument('--kiosk')
        # option.headless = True
        browser = webdriver.Firefox(options=option)
        browser.implicitly_wait(5)
        request.addfinalizer(browser.quit)
        return browser
    else:
        raise Exception(f'{request.param} is not supported!')
Exemplo n.º 2
0
def test_example():
    gdd = GeckoDriverManager()
    gdd.download_and_install()
    option = FirefoxOptions()
    # option.add_argument("--kiosk")
    # option.headless = True
    wd = webdriver.Firefox(options=option)
    wd.get("http://site2015.vagrant2.devel.sweb.ru:10001/")
Exemplo n.º 3
0
def test_elements():
    gdd = GeckoDriverManager()
    gdd.download_and_install()
    option = FirefoxOptions()
    b = webdriver.Firefox(options=option)
    b.get("https://otus.ru/")
    assert b.title == 'Онлайн‑курсы для профессионалов, дистанционное обучение современным профессиям'
    b.close
Exemplo n.º 4
0
 def openFirefox():
     try:
         browser = webdriver.Firefox()
         return browser
     except WebDriverException:
         GeckoDriverManager.download_and_install()
         browser = webdriver.Firefox()
         return browser
Exemplo n.º 5
0
def test_example():
    gdd = GeckoDriverManager()
    gdd.download_and_install()
    option = FirefoxOptions()
    option.add_argument("--kiosk")
    # option.headless = True
    wd = webdriver.Firefox(options=option)
    wd.get("https://otus.ru/")
    assert wd.title == 'Онлайн‑курсы для профессионалов, дистанционное обучение современным профессиям'
    wd.quit()
Exemplo n.º 6
0
    def firefox(self):
        from webdrivermanager import GeckoDriverManager
        gdd = GeckoDriverManager()
        path = gdd.download_and_install()
        print(path)

        try:
            self.driver = webdriver.Firefox()
            return
        except:
            print('firefox - not avaliable')

        raise
def test_example():
    """
    First test
    """
    #Создаем объект менеджер
    gdd = GeckoDriverManager()
    gdd.download_and_install()
    # proxy = Proxy("http://user@password:proxy.example.com:123")
    option = FirefoxOptions()
    option.set_capability("browserName", "chrome")
    wd = webdriver.Firefox(options=option)
    wd.get("https://otus.ru/")
    assert wd.title == 'Онлайн‑курсы для профессионалов, дистанционное обучение современным профессиям'
    wd.quit()
Exemplo n.º 8
0
def get_geckodriver():
    for p in sys.path:
        if os.path.isfile(p + '\\Scripts\\geckodriver.exe'):
            logging.info('geckodriver is installed.')
            return True

    logging.info('geockodrive is not installed, downloading...')
    from webdrivermanager import GeckoDriverManager
    gdd = GeckoDriverManager()
    try:
        gdd.download_and_install()
        logging.info('geckodriver is installed.')
    except Exception:
        logging.exception('Not able to install geckodirver.\n')
Exemplo n.º 9
0
def start_browser():
    opts = Options()
    # if headless == "y":
    opts.add_argument("--headless")
    firefox_profile = webdriver.FirefoxProfile()
    firefox_profile.set_preference('permissions.default.image', 2)
    firefox_profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so',
                                   False)
    try:
        driver = Firefox(firefox_profile=firefox_profile, options=opts)
    except WebDriverException:
        print("Geckodriver not detected, it will now be downloaded...")
        gdd = GeckoDriverManager()
        gdd.download_and_install()
        driver = Firefox(firefox_profile=firefox_profile, options=opts)
    return driver
Exemplo n.º 10
0
def driver():
    geckodriver_executable_path = GeckoDriverManager().download_and_install(
    )[1]
    options = Options()
    options.headless = True
    driver = webdriver.Firefox(executable_path=geckodriver_executable_path,
                               options=options)
    yield driver
    driver.quit()
Exemplo n.º 11
0
def get_driver():
    """ Handles download and installation of a required webdriver according to parameters set in settings.ini """
    browser = cfg['meta']['Browser']

    if browser.lower() == 'firefox':
        driver = webdriver.Firefox(
            executable_path=GeckoDriverManager().download_and_install()[0])
    elif browser.lower() == 'chrome':
        driver = webdriver.Chrome(
            executable_path=ChromeDriverManager().download_and_install()[0])
    return driver
Exemplo n.º 12
0
def before_all(context):
    try:
        browser = context.config.userdata['browser']
    except KeyError as ke:
        browser = None
    if browser == "chrome" or browser == None:
        binary_driver = ChromeDriverManager().download_and_install()[0]
        context.driver = webdriver.Chrome(binary_driver)
    elif browser == "firefox":
        binary_driver = GeckoDriverManager().download_and_install()[0]
        context.driver = webdriver.Firefox(executable_path=binary_driver)
    context.wait = WebDriverWait(context.driver, 5)
Exemplo n.º 13
0
 def __init__(self, manual_mode=False, firefox_profile=None, firefox_binary=None,
              timeout=30, capabilities=None, proxy=None,
              executable_path="geckodriver", options=None,
              log_path="geckodriver.log", firefox_options=None,
              service_args=None, desired_capabilities=None):
     if not manual_mode:
         executable_path = GeckoDriverManager().download_and_install()[0]
         os.environ["webdriver.firefox.driver"] = executable_path
     super(Firefox, self).__init__(firefox_profile=firefox_profile, firefox_binary=firefox_binary,
                                   timeout=timeout, capabilities=capabilities, proxy=proxy,
                                   executable_path=executable_path, options=options,
                                   log_path=log_path, firefox_options=firefox_options,
                                   service_args=service_args, desired_capabilities=desired_capabilities)
Exemplo n.º 14
0
def browser(request):
    browser = request.config.getoption()
    if browser == 'Firefox':
        gdm = GeckoDriverManager()
        gdm.download_and_install()
        option = FirefoxOptions()
        # option.add_argument('--kiosk')
        option.headless = True
        wd = webdriver.Firefox(options=option)
        request.addfinalizer(wd.quit)
        return wd
    if browser == 'Chrome':
        cdm = ChromeDriverManager()
        cdm.download_and_install()
        option = ChromeOptions()
        # option.add_argument('--kiosk')
        # option.add_argument('--ignore-certificate-errors')
        option.headless = True
        wd = webdriver.Chrome(options=option)
        request.addfinalizer(wd.quit)
        return wd
    else:
        raise Exception(f'{request.param} is not supported!')
Exemplo n.º 15
0
 def download_newest_webdriver(self, dir_path, browser):
     browser_l = str(browser).lower()
     if browser_l == "firefox":
         #downlaod firefox
         GeckoDriverManager(download_root=dir_path,
                            link_path=dir_path,
                            bitness="64").download_and_install()
         print("Firefox driver downloaded " + dir_path)
     elif browser_l == "chrome":
         #download chrome
         ChromeDriverManager(download_root=dir_path,
                             link_path=dir_path,
                             bitness="64").download_and_install()
         print("Chrome driver downloaded " + dir_path)
     else:
         print("atm there is only support for firefox, chrome")
def _create_driver(browser='Chrome'):
    '''
    Creates a driver
    '''
    global driver

    manager = {
        "Chrome": ChromeDriverManager(),
        "Edge": EdgeDriverManager(),
        "Firefox": GeckoDriverManager(),
        "Opera": OperaChromiumDriverManager()
    }
    drivers = {
        "Chrome": Chrome,
        "Edge": Edge,
        "Firefox": Firefox,
        "Opera": Opera
    }

    manager[browser].download_and_install()
    driver = drivers[browser]()
Exemplo n.º 17
0
from selenium import webdriver
from webdrivermanager import ChromeDriverManager
from webdrivermanager import GeckoDriverManager

broswer = 'firefox'

if broswer == 'chrome':
    driver = webdriver.Chrome(ChromeDriverManager().download_and_install())

elif broswer == 'firefox':
    driver = webdriver.Firefox(
        executable_path=GeckoDriverManager().download_and_install())

else:
    print('give valid web broswer name')

driver = webdriver.Chrome()
driver.get('http://facebook.com\login')

driver.find_element_by_id('email').send_keys(9704091318)
driver.find_element_by_id('pass').send_keys('sivaram1')
driver.find_element_by_id('loginbutton').click()
Exemplo n.º 18
0
def install_gecko_driver():
    gdd = GeckoDriverManager()
    gdd.download_and_install()
def Download_FireFoxDriver():
    GeckoDriverManager().download_and_install()
Exemplo n.º 20
0
Arquivo: main.py Projeto: patevs/misc
'''


# -------------------------------

# IMPORTS

from webdrivermanager import GeckoDriverManager
from selenium import webdriver

# -------------------------------


# GLOBAL VARIABLES

gdd = GeckoDriverManager()
driver = None

target = "https://www.newworld.co.nz/"
mailer = target + "savings/virtualmailer/"

# Main method
def main():
    print("\n  ---- Supo Scrapper ----")

    print("\n\tDownload and install GeckoDriver...")
    gdd.download_and_install()

    print("\n\tStarting Firefox...")
    driver = webdriver.Firefox()
Exemplo n.º 21
0
 def setUpClass(cls):
     super(SeleniumTestCase, cls).setUpClass()
     gdd = GeckoDriverManager()
     gdd.download_and_install()
Exemplo n.º 22
0
from urllib.request import Request, urlopen
from bs4 import BeautifulSoup, Comment
import bs4
import ssl
import operator
from selenium import webdriver
from webdrivermanager import GeckoDriverManager
import os
import json
from EditDistance import Trie
from selenium.webdriver.common.keys import Keys
import re
from selenium.webdriver.firefox.options import Options
gdd = GeckoDriverManager()
classnames = {}
options = Options()
options.headless = True


def visit(node):
    if isinstance(node, bs4.element.Tag):
        if (node.get('class')):
            #print(type(node), 'tag:', node.get('class'))
            classname_list = node.get('class')
            strval = ','.join(classname_list)
            if (strval in classnames):
                classnames[strval] += 1
            else:
                classnames[strval] = 1

    elif isinstance(node, bs4.element.NavigableString):
Exemplo n.º 23
0
 def setUpClass(cls):
     super(SeleniumTestCase, cls).setUpClass()
     gdd = GeckoDriverManager()
     gdd.download_and_install()
Exemplo n.º 24
0
def SetupWebdriver():
    from webdrivermanager import GeckoDriverManager
    gdd = GeckoDriverManager()
    gdd.download_and_install()