Python selenium.webdriver.ChromeOptions() Examples

The following are 30 code examples for showing how to use selenium.webdriver.ChromeOptions(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module selenium.webdriver , or try the search function .

Example 1
Project: MPContribs   Author: materialsproject   File: views.py    License: MIT License 17 votes vote down vote up
def get_browser():
    if "browser" not in g:
        options = webdriver.ChromeOptions()
        options.add_argument("no-sandbox")
        options.add_argument("--disable-gpu")
        options.add_argument("--window-size=800,600")
        options.add_argument("--disable-dev-shm-usage")
        options.set_headless()
        host = "chrome" if current_app.config["DEBUG"] else "127.0.0.1"
        g.browser = webdriver.Remote(
            command_executor=f"http://{host}:4444/wd/hub",
            desired_capabilities=DesiredCapabilities.CHROME,
            options=options,
        )
    return g.browser 
Example 2
Project: NoXss   Author: lwzSoviet   File: util.py    License: MIT License 11 votes vote down vote up
def chrome(headless=False):
    # support to get response status and headers
    d = DesiredCapabilities.CHROME
    d['loggingPrefs'] = {'performance': 'ALL'}
    opt = webdriver.ChromeOptions()
    if headless:
        opt.add_argument("--headless")
    opt.add_argument("--disable-xss-auditor")
    opt.add_argument("--disable-web-security")
    opt.add_argument("--allow-running-insecure-content")
    opt.add_argument("--no-sandbox")
    opt.add_argument("--disable-setuid-sandbox")
    opt.add_argument("--disable-webgl")
    opt.add_argument("--disable-popup-blocking")
    # prefs = {"profile.managed_default_content_settings.images": 2,
    #          'notifications': 2,
    #          }
    # opt.add_experimental_option("prefs", prefs)
    browser = webdriver.Chrome(options=opt,desired_capabilities=d)
    browser.implicitly_wait(10)
    browser.set_page_load_timeout(20)
    return browser 
Example 3
Project: scripts   Author: KiriKira   File: ipip.py    License: MIT License 10 votes vote down vote up
def create_driver():
    option = webdriver.ChromeOptions()
    option.add_argument("--headless")
    option.add_argument("--host-resolver-rules=MAP www.google-analytics.com 127.0.0.1")
    option.add_argument('user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36')
    return webdriver.Chrome(options=option) 
Example 4
Project: king-bot   Author: breuerfelix   File: custom_driver.py    License: MIT License 10 votes vote down vote up
def headless(self, path: str, proxy: str = "") -> None:
        ua = UserAgent()
        userAgent = ua.random
        options = webdriver.ChromeOptions()
        options.add_argument("headless")
        options.add_argument("window-size=1500,1200")
        options.add_argument("no-sandbox")
        options.add_argument("disable-dev-shm-usage")
        options.add_argument("disable-gpu")
        options.add_argument("log-level=3")
        options.add_argument(f"user-agent={userAgent}")

        if proxy != "":
            self.proxy = True
            options.add_argument("proxy-server={}".format(proxy))

        self.driver = webdriver.Chrome(path, chrome_options=options)
        self.set_config()
        self._headless = True 
Example 5
Project: realbrowserlocusts   Author: nickboucart   File: locusts.py    License: MIT License 9 votes vote down vote up
def __init__(self):
        super(HeadlessChromeLocust, self).__init__()
        options = webdriver.ChromeOptions()
        options.add_argument('headless')
        options.add_argument('window-size={}x{}'.format(
            self.screen_width, self.screen_height
        ))
        options.add_argument('disable-gpu')
        if self.proxy_server:
            _LOGGER.info('Using proxy: ' + self.proxy_server)
            options.add_argument('proxy-server={}'.format(self.proxy_server))
        driver = webdriver.Chrome(chrome_options=options)
        _LOGGER.info('Actually trying to run headless Chrome')
        self.client = RealBrowserClient(
            driver,
            self.timeout,
            self.screen_width,
            self.screen_height,
            set_window=False
        ) 
Example 6
Project: ankigenbot   Author: damaru2   File: send_card.py    License: GNU General Public License v3.0 9 votes vote down vote up
def __init__(self, username, password):
        self.driver = None

        self.last_access = time.time()

        options = webdriver.ChromeOptions()
        options.add_argument("--window-size=1920x1080")
        options.add_argument('--ignore-certificate-errors')
        options.add_argument('--headless')
        options.add_argument('--no-sandbox')
        options.add_argument('--disable-dev-shm-usage')

        options.binary_location = "/usr/lib/chromium-browser/chromium-browser"
        self.driver = webdriver.Chrome(chrome_options=options)

        self.driver.set_window_size(1920, 1080)
        self.driver.get(CardSender.url)
        usr_box = self.driver.find_element_by_id('email')
        usr_box.send_keys(username)
        pass_box = self.driver.find_element_by_id('password')
        pass_box.send_keys('{}\n'.format(password)) 
Example 7
Project: wagtail-tag-manager   Author: jberghoef   File: fixtures.py    License: BSD 3-Clause "New" or "Revised" License 8 votes vote down vote up
def driver():
    options = webdriver.ChromeOptions()
    options.add_argument("disable-gpu")
    options.add_argument("headless")
    options.add_argument("no-default-browser-check")
    options.add_argument("no-first-run")
    options.add_argument("no-sandbox")

    d = DesiredCapabilities.CHROME
    d["loggingPrefs"] = {"browser": "ALL"}

    driver = webdriver.Chrome(options=options, desired_capabilities=d)
    driver.implicitly_wait(30)

    yield driver
    driver.quit() 
Example 8
Project: python-sdk   Author: kuaidaili   File: selenium_chrome_http_auth.py    License: BSD 2-Clause "Simplified" License 8 votes vote down vote up
def get_chromedriver(use_proxy=False, user_agent=None):
    # path = os.path.dirname(os.path.abspath(__file__)) # 如果没有把chromedriver放到python\script\下,则需要指定路径
    chrome_options = webdriver.ChromeOptions()
    if use_proxy:
        pluginfile = 'proxy_auth_plugin.zip'

        with zipfile.ZipFile(pluginfile, 'w') as zp:
            zp.writestr("manifest.json", manifest_json)
            zp.writestr("background.js", background_js)
        chrome_options.add_extension(pluginfile)
    if user_agent:
        chrome_options.add_argument('--user-agent=%s' % user_agent)
    driver = webdriver.Chrome(
        # os.path.join(path, 'chromedriver'),
        chrome_options=chrome_options)
    return driver 
Example 9
Project: content   Author: demisto   File: rasterize.py    License: MIT License 8 votes vote down vote up
def init_driver(offline_mode=False):
    """
    Creates headless Google Chrome Web Driver
    """
    demisto.debug(f'Creating chrome driver. Mode: {"OFFLINE" if offline_mode else "ONLINE"}')
    try:
        chrome_options = webdriver.ChromeOptions()
        for opt in merge_options(DEFAULT_CHROME_OPTIONS, USER_CHROME_OPTIONS):
            chrome_options.add_argument(opt)
        driver = webdriver.Chrome(options=chrome_options, service_args=[
            f'--log-path={DRIVER_LOG}',
        ])
        if offline_mode:
            driver.set_network_conditions(offline=True, latency=5, throughput=500 * 1024)
    except Exception as ex:
        return_error(f'Unexpected exception: {ex}\nTrace:{traceback.format_exc()}')

    demisto.debug('Creating chrome driver - COMPLETED')
    return driver 
Example 10
Project: online-judge   Author: DMOJ   File: pdf_problems.py    License: GNU Affero General Public License v3.0 7 votes vote down vote up
def _make(self, debug):
        options = webdriver.ChromeOptions()
        options.add_argument("--headless")
        options.binary_location = settings.SELENIUM_CUSTOM_CHROME_PATH

        browser = webdriver.Chrome(settings.SELENIUM_CHROMEDRIVER_PATH, options=options)
        browser.get('file://' + os.path.abspath(os.path.join(self.dir, 'input.html')))
        self.log = self.get_log(browser)

        try:
            WebDriverWait(browser, 15).until(EC.presence_of_element_located((By.CLASS_NAME, 'math-loaded')))
        except TimeoutException:
            logger.error('PDF math rendering timed out')
            self.log = self.get_log(browser) + '\nPDF math rendering timed out'
            return

        response = browser.execute_cdp_cmd('Page.printToPDF', self.template)
        self.log = self.get_log(browser)
        if not response:
            return

        with open(os.path.abspath(os.path.join(self.dir, 'output.pdf')), 'wb') as f:
            f.write(base64.b64decode(response['data']))

        self.success = True 
Example 11
Project: Python-tools   Author: wolverinn   File: power_views.py    License: MIT License 7 votes vote down vote up
def get_page(url):
    chrome_options = webdriver.ChromeOptions()
    ua_argument = 'User-Agent="'+GetUserAgent()+'"'
    chrome_options.add_argument(ua_argument)
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')
    chrome_options.add_argument('--incognito')
    chrome_options.add_argument('log-level=3')
    try:
        driver = webdriver.Chrome(chrome_options=chrome_options)
        #driver.set_page_load_timeout(6)
        # driver.set_script_timeout(6)
        driver.get(url)
        # time.sleep(0.5)
        driver.quit()
    except:
        driver.quit()
        print("timeout") 
Example 12
Project: toolium   Author: Telefonica   File: config_driver.py    License: Apache License 2.0 6 votes vote down vote up
def _create_chrome_options(self):
        """Create and configure a chrome options object

        :returns: chrome options object
        """
        # Get Chrome binary
        chrome_binary = self.config.get_optional('Chrome', 'binary')

        # Create Chrome options
        options = webdriver.ChromeOptions()

        if self.config.getboolean_optional('Driver', 'headless'):
            self.logger.debug("Running Chrome in headless mode")
            options.add_argument('--headless')
            if os.name == 'nt':  # Temporarily needed if running on Windows.
                options.add_argument('--disable-gpu')

        if chrome_binary is not None:
            options.binary_location = chrome_binary

        # Add Chrome preferences, mobile emulation options and chrome arguments
        self._add_chrome_options(options, 'prefs')
        self._add_chrome_options(options, 'mobileEmulation')
        self._add_chrome_arguments(options)

        return options 
Example 13
Project: vrequest   Author: cilame   File: middlewares.py    License: MIT License 6 votes vote down vote up
def _open_webdriver(self): # 该函数同时作为重启 webdriver 功能使用
        try: self.spider_closed()
        except: pass
        from selenium import webdriver
        option = webdriver.ChromeOptions()
        extset = ['enable-automation', 'ignore-certificate-errors']
        ignimg = "profile.managed_default_content_settings.images"
        mobile = {'deviceName':'Galaxy S5'}
        option.add_argument("--disable-infobars")                       # 旧版本关闭“chrome正受到自动测试软件的控制”信息
        option.add_experimental_option("excludeSwitches", extset)       # 新版本关闭“chrome正受到自动测试软件的控制”信息
        option.add_experimental_option("useAutomationExtension", False) # 新版本关闭“请停用以开发者模式运行的扩展程序”信息
        # option.add_experimental_option('mobileEmulation', mobile)     # 是否使用手机模式打开浏览器
        # option.add_experimental_option("prefs", {ignore_image: 2})    # 开启浏览器时不加载图片(headless模式该配置无效)
        # option.add_argument('--start-maximized')                      # 开启浏览器时是否最大化(headless模式该配置无效)
        # option.add_argument('--headless')                             # 无界面打开浏览器
        # option.add_argument('--window-size=1920,1080')                # 无界面打开浏览器时候只能用这种方式实现最大化
        # option.add_argument('--disable-gpu')                          # 禁用 gpu 硬件加速
        # option.add_argument("--auto-open-devtools-for-tabs")          # 开启浏览器时候是否打开开发者工具(F12)
        # option.add_argument("--user-agent=Mozilla/5.0 HELL")          # 修改 UA 信息
        # option.add_argument('--proxy-server=http://127.0.0.1:8888')   # 增加代理
        self.webdriver = webdriver.Chrome(chrome_options=option) 
Example 14
Project: SupervisedChromeTrex   Author: asingh33   File: mychrome.py    License: MIT License 6 votes vote down vote up
def setup():
    chrome_options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', chrome_options=chrome_options)
    driver.set_window_size(800, 600)
    #Open Dino game page in Chrome
    driver.get('chrome://dino/')
    return driver
    
#This function will send the SPACE key to make dino jump 
Example 15
Project: WhatsApp-Scraping   Author: JMGama   File: scraper.py    License: Apache License 2.0 6 votes vote down vote up
def load_driver(settings):
    """
    Load the Selenium driver depending on the browser
    (Edge and Safari are not running yet)
    """
    driver = None
    if settings['browser'] == 'firefox':
        firefox_profile = webdriver.FirefoxProfile(settings['browser_path'])
        driver = webdriver.Firefox(firefox_profile)
    elif settings['browser'] == 'chrome':
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('user-data-dir=' +
                                    settings['browser_path'])
        driver = webdriver.Chrome(options=chrome_options)
    elif settings['browser'] == 'safari':
        pass
    elif settings['browser'] == 'edge':
        pass

    return driver 
Example 16
Project: expressvpn_leak_testing   Author: expressvpn   File: webdriver.py    License: MIT License 6 votes vote down vote up
def driver(self, browser):
        if browser == 'firefox':
            return webdriver.Firefox()
        if browser == 'chrome':
            return webdriver.Chrome('chromedriver.exe')
        if browser == 'opera':
            # TODO: Opera implementation is quite buggy annoyingly. It won't close at the moment
            # Need to investigate.
            options = webdriver.ChromeOptions()
            options.binary_location = "C:\\Program Files\\Opera\\launcher.exe"
            return  webdriver.Opera(executable_path='operadriver.exe', opera_options=options)
        if browser == 'ie':
            return webdriver.Ie()
        if browser == 'edge':
            # TODO: check for Windows < 8.1?
            return webdriver.Edge()
        if browser == 'phantom':
            return webdriver.PhantomJS()
        raise XVEx("{} is not supported on {}".format(browser, self._device.os_name())) 
Example 17
Project: psd2svg   Author: kyamagu   File: chromium_rasterizer.py    License: MIT License 6 votes vote down vote up
def __init__(self, executable_path="chromedriver", dpi=96.0, **kwargs):
        options = webdriver.ChromeOptions()
        options.add_argument("headless")
        options.add_argument("disable-gpu")
        options.add_argument("disable-infobars")
        options.add_argument("no-sandbox")
        options.add_argument("disable-dev-shm-usage")
        options.add_argument("enable-experimental-web-platform-features")
        options.add_argument("default-background-color FFFFFF00")
        self.driver = webdriver.Chrome(
            executable_path=executable_path,
            options=options)
        self.dpi = dpi
        self.driver.execute_cdp_cmd(
            "Emulation.setDefaultBackgroundColorOverride",
            {'color': {'r': 255, 'g': 255, 'b': 255, 'a': 0}}
        ) 
Example 18
Project: PaperScraper   Author: NLPatVCU   File: PaperScraper.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, webdriver_path=None):
        """Creates a PaperScraper object

        Initializes a PaperScraper that can scrape text and meta-data from scientific journals. Individual journal
        scrapers and journal link aggregators are implemented in :mod:'scrapers' and :mod:'aggregators'.

        :param webdriver_path: The file path of a custom web driver to utilize, defaults to utilize the chromedriver
            that comes installed with the package.
        :type webdriver_path: str.

        """
        options = webdriver.ChromeOptions()
        options.add_argument('headless')

        webdriver_path = pkg_resources.resource_filename('paperscraper', 'webdrivers/chromedriver')

        if ('webdriver_path' is not None):
            self.webdriver_path = webdriver_path

        self.driver = webdriver.Chrome(webdriver_path, options=options) 
Example 19
Project: realbrowserlocusts   Author: nickboucart   File: locusts.py    License: MIT License 5 votes vote down vote up
def __init__(self):
        super(ChromeLocust, self).__init__()
        options = webdriver.ChromeOptions()
        if self.proxy_server:
            _LOGGER.info('Using proxy: ' + self.proxy_server)
            options.add_argument('proxy-server={}'.format(self.proxy_server))
        self.client = RealBrowserClient(
            webdriver.Chrome(chrome_options=options),
            self.timeout,
            self.screen_width,
            self.screen_height
        ) 
Example 20
Project: Web-Spider-Login-Bilibili-Python3   Author: wmylxmj   File: bilibililogin.py    License: MIT License 5 votes vote down vote up
def __init__(self, username, password, windowsize=(750, 800), executable_path="chromedriver"):
        '''
        function: parameters initialize
        input username: username
        input password: password
        input windowsize: windowsize
        input executable_path: the path of chromedriver
        return none
        '''
        # the login url
        self.url = 'https://passport.bilibili.com/login'
        # the blowaer
        chrome_options = webdriver.ChromeOptions()
        if windowsize != 'max':
            (m, n) = windowsize
            self.set_window_size = '--window-size='+str(m)+','+str(n)
            pass
        else:
            self.set_window_size = '--start-maximized'
            pass
        chrome_options.add_argument(self.set_window_size)
        self.executable_path = executable_path
        self.browser = webdriver.Chrome(executable_path=executable_path, options = chrome_options)        
        # username
        self.username = username
        # password
        self.password = password
        self.wait = WebDriverWait(self.browser, 100)
        self.border = 6
        # if logged in
        self.have_logged_in = False
        self.author = 'wmylxmj'
        pass 
Example 21
Project: ir   Author: guilhermecgs   File: selenium_config.py    License: Mozilla Public License 2.0 5 votes vote down vote up
def configure_driver(headless=False):
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--no-sandbox')
    if headless:
        chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')
    driver = webdriver.Chrome(options=chrome_options)
    driver.implicitly_wait(20)
    return driver 
Example 22
Project: Disney-Fastpass-Bot   Author: ethanbrimhall   File: fastpassfinder.py    License: MIT License 5 votes vote down vote up
def createChromeDriver():
    print("\nOpening Chrome WebDriver...")
    options = webdriver.ChromeOptions()
    options.add_argument("--start-maximized")
    chrome_path = credentials.path

    return webdriver.Chrome(chrome_path, options=options)

#Clicks the first button on the website, the 'get started' button 
Example 23
Project: google-arts-crawler   Author: Boquete   File: __init__.py    License: GNU General Public License v3.0 5 votes vote down vote up
def chrome_options(self) -> ChromeOptions:
        return self._chrome_options 
Example 24
Project: google-arts-crawler   Author: Boquete   File: __init__.py    License: GNU General Public License v3.0 5 votes vote down vote up
def set_chrome_options(self, chrome_options: ChromeOptions):
        self._chrome_options = chrome_options
        return self 
Example 25
Project: makemework   Author: qxf2   File: DriverFactory.py    License: MIT License 5 votes vote down vote up
def run_local(self,os_name,os_version,browser,browser_version):
        "Return the local driver"
        local_driver = None
        if browser.lower() == "ff" or browser.lower() == 'firefox':
            local_driver = webdriver.Firefox()    
        elif  browser.lower() == "ie":
            local_driver = webdriver.Ie()
        elif browser.lower() == "chrome":
            local_driver = webdriver.Chrome()
        elif browser.lower() == "opera":
            opera_options = None
            try:
                opera_browser_location = opera_browser_conf.location
                options = webdriver.ChromeOptions()
                options.binary_location = opera_browser_location # path to opera executable
                local_driver = webdriver.Opera(options=options)
                    
            except Exception as e:
                print("\nException when trying to get remote webdriver:%s"%sys.modules[__name__])
                print("Python says:%s"%str(e))
                if  'no Opera binary' in str(e):
                     print("SOLUTION: It looks like you are trying to use Opera Browser. Please update Opera Browser location under conf/opera_browser_conf.\n")
        elif browser.lower() == "safari":
            local_driver = webdriver.Safari()

        return local_driver 
Example 26
Project: ESPN-Fantasy-Basketball   Author: wcrasta   File: app.py    License: MIT License 5 votes vote down vote up
def run_selenium(url, is_season_data, league_id):
    options = webdriver.ChromeOptions()
    options.add_argument('headless')
    options.add_argument('no-sandbox')
    options.add_argument('disable-dev-shm-usage')
    capa = DesiredCapabilities.CHROME
    capa["pageLoadStrategy"] = "none"
    driver = webdriver.Chrome(chrome_options=options, desired_capabilities=capa)
    try:
        app.logger.info('%s - Starting selenium', league_id)
        driver.get(url)
        app.logger.info('%s - Waiting for element to load', league_id)
        # Season standings have a different URL than weekly scoreboard

        if is_season_data:
            WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.CLASS_NAME, 'Table2__sub-header')))
        else:
            WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.CLASS_NAME, 'Table2__header-row')))
        app.logger.info('%s - Element loaded. Sleeping started to get latest data.', league_id)
        time.sleep(5)
        plain_text = driver.page_source
        soup = BeautifulSoup(plain_text, 'html.parser')
        app.logger.info('%s - Got BeautifulSoup object', league_id)
    except Exception as ex:
        app.logger.error('%s - Could not get page source.', league_id, ex)
        soup = None
    finally:
        driver.quit()
    return soup 
Example 27
Project: webdriver_manager   Author: SergeyPirogov   File: test_opera_manager.py    License: Apache License 2.0 5 votes vote down vote up
def test_operadriver_manager_with_selenium():
    driver_path = OperaDriverManager().install()
    options = webdriver.ChromeOptions()
    options.add_argument('allow-elevated-browser')

    if get_os_type() in ["win64", "win32"]:
        paths = [f for f in glob.glob(f"C:/Users/{os.getlogin()}/AppData/" \
                                      "Local/Programs/Opera/**",
                                      recursive=True)]
        for path in paths:
            if os.path.isfile(path) and path.endswith("opera.exe"):
                options.binary_location = path
    elif ((get_os_type() in ["linux64", "linux32"]) and not
          os.path.exists('/usr/bin/opera')):
        options.binary_location = "/usr/bin/opera"
    elif get_os_type() in "mac64":
        options.binary_location = "/Applications/Opera.app/Contents/MacOS/Opera"

    ff = webdriver.Opera(executable_path=driver_path, options=options)
    ff.get("http://automation-remarks.com")
    ff.quit() 
Example 28
Project: wagtail-tag-manager   Author: jberghoef   File: webdriver.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def init_browser(self):
        options = webdriver.ChromeOptions()
        options.add_argument("disable-gpu")
        options.add_argument("headless")
        options.add_argument("no-default-browser-check")
        options.add_argument("no-first-run")
        options.add_argument("no-sandbox")

        self.browser = webdriver.Remote(
            getattr(settings, "WTM_CHROMEDRIVER_URL", "http://0.0.0.0:4444/wd/hub"),
            DesiredCapabilities.CHROME,
            options=options,
        )
        self.browser.implicitly_wait(30) 
Example 29
Project: csb   Author: danielyc   File: bot.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def openChrome(paydetailsO, itemdetsO, timeO, strictO, skipO, nextO, cdloc, capabilities, useProxy, PROXY):
    global driver, strict, password, reg, items, droptime, pDescr, paydetails, category, skipS, nextS
    chrome_options = webdriver.ChromeOptions()
    if useProxy:
        prx = Proxy()
        prx.proxy_type = ProxyType.MANUAL
        prx.http_proxy = PROXY
        prx.socks_proxy = PROXY
        prx.ssl_proxy = PROXY
        prx.add_to_capabilities(capabilities)
    else:
        prx = Proxy()
        prx.proxy_type = ProxyType.SYSTEM
        prx.add_to_capabilities(capabilities)

    chrome_options.binary_location = capabilities['chrome.binary']

    driver = webdriver.Chrome(cdloc, desired_capabilities=capabilities)
    openTab('https://www.google.com', driver)
    paydetails = paydetailsO
    reg = paydetailsO['Region']
    strict = strictO
    skipS = skipO
    nextS = nextO
    droptime = timeO
    items = []
    for x in itemdetsO:
        print(x[0],x[1],x[2],x[3])
        items.append({'selectedCategory': x[0], 'keywords': x[1].split(','), 'selectedColour': x[2], 'selectedSize': x[3]})
    returnTime()
    try:
        for it in items:
                searchItem(it)
        cart()
    except NoSuchWindowException:
        print('[!] Chrome window closed. Click GO! to re-start')
        return None 
Example 30
Project: qxf2-page-object-model   Author: qxf2   File: DriverFactory.py    License: MIT License 5 votes vote down vote up
def run_local(self,os_name,os_version,browser,browser_version):
        "Return the local driver"
        local_driver = None
        if browser.lower() == "ff" or browser.lower() == 'firefox':
            local_driver = webdriver.Firefox()
        elif  browser.lower() == "ie":
            local_driver = webdriver.Ie()
        elif browser.lower() == "chrome":
            local_driver = webdriver.Chrome()
        elif browser.lower() == "opera":
            try:
                opera_browser_location = opera_browser_conf.location
                options = webdriver.ChromeOptions()
                options.binary_location = opera_browser_location # path to opera executable
                local_driver = webdriver.Opera(options=options)

            except Exception as e:
                print("\nException when trying to get remote webdriver:%s"%sys.modules[__name__])
                print("Python says:%s"%str(e))
                if  'no Opera binary' in str(e):
                     print("SOLUTION: It looks like you are trying to use Opera Browser. Please update Opera Browser location under conf/opera_browser_conf.\n")
        elif browser.lower() == "safari":
            local_driver = webdriver.Safari()

        return local_driver