当前位置: 首页>>代码示例>>Python>>正文


Python webdriver.Opera方法代码示例

本文整理汇总了Python中selenium.webdriver.Opera方法的典型用法代码示例。如果您正苦于以下问题:Python webdriver.Opera方法的具体用法?Python webdriver.Opera怎么用?Python webdriver.Opera使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver的用法示例。


在下文中一共展示了webdriver.Opera方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_operadriver_manager_with_selenium

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
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() 
开发者ID:SergeyPirogov,项目名称:webdriver_manager,代码行数:23,代码来源:test_opera_manager.py

示例2: driver

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
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())) 
开发者ID:expressvpn,项目名称:expressvpn_leak_testing,代码行数:21,代码来源:webdriver.py

示例3: browser

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
def browser(request):
    browser_type = os.environ.get('AVA_TEST_BROWSER', 'Firefox')

    if browser_type == 'PhantomJS':
        b = webdriver.PhantomJS()
    if browser_type == 'Chrome':
        b = webdriver.Chrome()
    elif browser_type == 'Opera':
        b = webdriver.Opera()
    elif browser_type == 'IE':
        b = webdriver.Ie()
    elif browser_type == 'Safari':
        b = webdriver.Safari()
    elif browser_type == 'Remote':
        b = webdriver.Remote()
    else:
        b = webdriver.Firefox()

    b.implicitly_wait(5)

    def teardown_browser():
        b.quit()
    request.addfinalizer(teardown_browser)

    return b 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:27,代码来源:webpages.py

示例4: main

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
def main():
	driver_type = int(input("1) Firefox | 2) Chrome | 3) IE | 4) Opera | 5) PhantomJS\nEnter the driver you want to use: "))
	wordsToSearch = input("Enter the words: ").split(',')
	for w in wordsToSearch:
		w = w.strip()
	start_date = input("Enter the start date in (Y-M-D): ")
	end_date = input("Enter the end date in (Y-M-D): ")
	lang = int(input("0) All Languages 1) English | 2) Italian | 3) Spanish | 4) French | 5) German | 6) Russian | 7) Chinese\nEnter the language you want to use: "))
	all_dates = get_all_dates(start_date, end_date)
	print(all_dates)
	for i in range(len(all_dates) - 1):
		driver = init_driver(driver_type)
		scroll(driver, str(all_dates[i]), str(all_dates[i + 1]), wordsToSearch, lang)
		scrape_tweets(driver)
		time.sleep(5)
		print("The tweets for {} are ready!".format(all_dates[i]))
		driver.quit() 
开发者ID:prakharchoudhary,项目名称:TwitterAdvSearch,代码行数:19,代码来源:scraper.py

示例5: _setup_opera

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
def _setup_opera(self, capabilities):
        """Setup Opera webdriver

        :param capabilities: capabilities object
        :returns: a new local Opera driver
        """
        opera_driver = self.config.get('Driver', 'opera_driver_path')
        self.logger.debug("Opera driver path given in properties: %s", opera_driver)
        return webdriver.Opera(executable_path=opera_driver, desired_capabilities=capabilities) 
开发者ID:Telefonica,项目名称:toolium,代码行数:11,代码来源:config_driver.py

示例6: run_local

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
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 
开发者ID:qxf2,项目名称:makemework,代码行数:28,代码来源:DriverFactory.py

示例7: test_opera_driver_manager_with_wrong_version

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
def test_opera_driver_manager_with_wrong_version():
    with pytest.raises(ValueError) as ex:
        driver_path = OperaDriverManager("0.2").install()
        ff = webdriver.Opera(executable_path=driver_path)
        ff.quit()
    assert "There is no such driver by url " \
           "https://api.github.com/repos/operasoftware/operachromiumdriver/" \
           "releases/tags/0.2" in ex.value.args[0] 
开发者ID:SergeyPirogov,项目名称:webdriver_manager,代码行数:10,代码来源:test_opera_manager.py

示例8: get_webdriver

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
def get_webdriver():
    """Get whatever webdriver is availiable in the system.
    webdriver_manager and selenium are currently being used for this.
    Supported browsers:[Firefox, Chrome, Opera, Microsoft Edge, Internet Expolorer]
    Returns:
            a webdriver that can be used for scraping. Returns None if we don't find a supported webdriver.

    """
    try:
        driver = webdriver.Firefox(
            executable_path=GeckoDriverManager().install())
    except Exception:
        try:
            driver = webdriver.Chrome(ChromeDriverManager().install())
        except Exception:
            try:
                driver = webdriver.Ie(IEDriverManager().install())
            except Exception:
                try:
                    driver = webdriver.Opera(
                        executable_path=OperaDriverManager().install())
                except Exception:
                    try:
                        driver = webdriver.Edge(
                            EdgeChromiumDriverManager().install())
                    except Exception:
                        driver = None
                        logging.error(
                            "Your browser is not supported. Must have one of the following installed to scrape: [Firefox, Chrome, Opera, Microsoft Edge, Internet Expolorer]")

    return driver 
开发者ID:PaulMcInnis,项目名称:JobFunnel,代码行数:33,代码来源:tools.py

示例9: run_local

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
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 
开发者ID:qxf2,项目名称:qxf2-page-object-model,代码行数:27,代码来源:DriverFactory.py

示例10: create_driver

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
def create_driver():
	try:
		web = webdriver.Firefox()
		print " [*] Opening Mozila FireFox..."
		return web
	except:
		try:
			web = webdriver.Chrome()
			print " [*] We got some errors running Firefox, Opening Google Chrome instead..."
			return web
		except:
			try:
				web = webdriver.Opera()
				print " [*] We got some errors running Chrome, Opening Opera instead..."
				return web
			except:
				try:
					web = webdriver.Edge()
					print " [*] We got some errors running Opera, Opening Edge instead..."
					return web
				except:
					try:
						web = webdriver.Ie()
						print " [*] We got some errors running Edge, Opening Internet Explorer instead..."
						return web
					except:
						print " Error: \n Can not call any WebBrowsers\n  Check your Installed Browsers!"
						exit()

#Stolen from stackoverflow :D 
开发者ID:vaginessa,项目名称:QRLJacking,代码行数:32,代码来源:QRLJacker.py

示例11: init_driver

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
def init_driver(driver_type):
	if driver_type == 1:
		driver = webdriver.Firefox()
	elif driver_type == 2:
		driver = webdriver.Chrome()
	elif driver_type == 3:
		driver = webdriver.Ie()
	elif driver_type == 4:
		driver = webdriver.Opera()
	elif driver_type == 5:
		driver = webdriver.PhantomJS()
	driver.wait = WebDriverWait(driver, 5)
	return driver 
开发者ID:prakharchoudhary,项目名称:TwitterAdvSearch,代码行数:15,代码来源:scraper.py

示例12: test_drivers

# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Opera [as 别名]
def test_drivers(pool_name='drivers', target_attr='selenium'):
    """
    Run tests with `target_attr` set to each instance in the `WebDriverPool`
    named `pool_name`.

    For example, in you setUpClass method of your LiveServerTestCase:

        # Importing the necessaries:
        from selenium import webdriver

        ### In your TestCase:

        # Be sure to add a place holder attribute for the driver variable
        selenium = None

        # Set up drivers
        @classmethod
        def setUpClass(cls):
            cls.drivers = WebDriverList(
                webdriver.Chrome(),
                webdriver.Firefox(),
                webdriver.Opera(),
                webdriver.PhantomJS,
            )
            super(MySeleniumTests, cls).setUpClass()

        # Tear down drivers
        @classmethod
        def tearDownClass(cls):
            cls.drivers.quit()
            super(MySeleniumTests, cls).tearDownClass()

        # Use drivers
        @test_drivers()
        def test_login(self):
            self.selenium.get('%s%s' % (self.live_server_url, '/'))
            self.assertEqual(self.selenium.title, 'Awesome Site')

    This will run `test_login` with each of the specified drivers as the
    attribute named "selenium"

    """
    def wrapped(test_func):
        @functools.wraps(test_func)
        def decorated(test_case, *args, **kwargs):
            test_class = test_case.__class__
            web_driver_pool = getattr(test_class, pool_name)
            for web_driver in web_driver_pool:
                setattr(test_case, target_attr, web_driver)
                test_func(test_case, *args, **kwargs)
        return decorated
    return wrapped 
开发者ID:idaholab,项目名称:civet,代码行数:54,代码来源:SeleniumTester.py


注:本文中的selenium.webdriver.Opera方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。