本文整理汇总了Python中selenium.webdriver.Ie方法的典型用法代码示例。如果您正苦于以下问题:Python webdriver.Ie方法的具体用法?Python webdriver.Ie怎么用?Python webdriver.Ie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver
的用法示例。
在下文中一共展示了webdriver.Ie方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: driver
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [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()))
示例2: browser
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [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
示例3: _setup_explorer
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [as 别名]
def _setup_explorer(self, capabilities):
"""Setup Internet Explorer webdriver
:param capabilities: capabilities object
:returns: a new local Internet Explorer driver
"""
explorer_driver = self.config.get('Driver', 'explorer_driver_path')
self.logger.debug("Explorer driver path given in properties: %s", explorer_driver)
return webdriver.Ie(explorer_driver, capabilities=capabilities)
示例4: run_local
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [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
示例5: test_ie_manager_with_selenium
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [as 别名]
def test_ie_manager_with_selenium():
driver_path = IEDriverManager().install()
if os.name == 'nt':
driver = webdriver.Ie(executable_path=driver_path)
driver.get("http://automation-remarks.com")
driver.quit()
else:
assert os.path.exists(driver_path)
示例6: get_webdriver
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [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
示例7: run_local
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [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
示例8: create_driver
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [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
示例9: test_IE
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [as 别名]
def test_IE():
sc = Screenshot()
driver = webdriver.Ie(executable_path=iedriver_path)
url = 'http://yandex.ru'
driver.get(url)
time.sleep(10)
sc.full_Screenshot(driver, save_path='.', image_name='testimage.png',load_wait_time=5,is_load_at_runtime=True)
driver.close()
driver.quit()
示例10: get_browser
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [as 别名]
def get_browser(browser_name, capabilities=None, **options):
"""
Returns an instance of the given browser with the given capabilities.
Args:
browser_name (str): The name of the desired browser.
capabilities (Dict[str, str | bool], optional): The desired capabilities of the browser.
Defaults to None.
options: Arbitrary keyword arguments for the browser-specific subclass of
:class:`webdriver.Remote`.
Returns:
WebDriver: An instance of the desired browser.
"""
if browser_name == "chrome":
return webdriver.Chrome(desired_capabilities=capabilities, **options)
if browser_name == "edge":
return webdriver.Edge(capabilities=capabilities, **options)
if browser_name in ["ff", "firefox"]:
return webdriver.Firefox(capabilities=capabilities, **options)
if browser_name in ["ie", "internet_explorer"]:
return webdriver.Ie(capabilities=capabilities, **options)
if browser_name == "phantomjs":
return webdriver.PhantomJS(desired_capabilities=capabilities, **options)
if browser_name == "remote":
return webdriver.Remote(desired_capabilities=capabilities, **options)
if browser_name == "safari":
return webdriver.Safari(desired_capabilities=capabilities, **options)
raise ValueError("unsupported browser: {}".format(repr(browser_name)))
示例11: init_driver
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [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
示例12: select_browser
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [as 别名]
def select_browser(browser_selection):
"""
Implements operating system checking to determine appropriate browser support
Raises exception when unsupported operating system or browser is found
Currently supported operating systems and browsers:
* Windows: Internet Explorer (IE), Firefox (FF), Chrome
* Linux: Firefox (FF), Chrome
Returns browser object corresponding to selection choice (browser_selection)
"""
if sys.platform == "win32":
current_path = sys.path[0]
if browser_selection == "IE":
ie_path = current_path + "\\IEDriver.exe"
return webdriver.Ie(ie_path)
elif browser_selection == "Chrome":
chrome_path = current_path + "\\ChromeDriver.exe"
return webdriver.Chrome(chrome_path)
# Firefox selenium implementation requires gecko executable to be in PATH
elif browser_selection == "FF":
firefox_driver_path = current_path + "\\FFDriver.exe"
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
return webdriver.Firefox(capabilities=firefox_capabilities, executable_path=firefox_driver_path)
else:
raise Exception("Invalid Windows browser selection (IE, Chrome, and FF supported)")
elif sys.platform == "linux" or sys.platform == "linux2":
current_path = os.path.dirname(os.path.abspath(__file__))
if browser_selection == "FF":
firefox_driver_path = current_path + "/FFDriver.bin"
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['executable_path'] = firefox_driver_path
return webdriver.Firefox(capabilities=firefox_capabilities)
elif browser_selection == "Chrome":
chrome_path = current_path + "/ChromeDriver.bin"
return webdriver.Chrome(chrome_path)
else:
raise Exception("Invalid Linux browser selection (Chrome and FF supported)")
else:
raise Exception("Operating system not supported")
示例13: _get_selenium_browser
# 需要导入模块: from selenium import webdriver [as 别名]
# 或者: from selenium.webdriver import Ie [as 别名]
def _get_selenium_browser(self):
"""Returns selenium webdriver instance of selected ``browser``.
Note: should not be called directly, use :meth:`get_browser` instead.
:raises: ValueError: If wrong ``browser`` specified.
"""
kwargs = {}
binary = settings.selenium.webdriver_binary
browseroptions = settings.selenium.browseroptions
if self.browser == 'chrome':
if binary:
kwargs.update({'executable_path': binary})
options = webdriver.ChromeOptions()
prefs = {'download.prompt_for_download': False}
options.add_experimental_option("prefs", prefs)
options.add_argument('disable-web-security')
options.add_argument('ignore-certificate-errors')
if browseroptions:
for opt in browseroptions.split(';'):
options.add_argument(opt)
kwargs.update({'options': options})
self._webdriver = webdriver.Chrome(**kwargs)
elif self.browser == 'firefox':
if binary:
kwargs.update({'executable_path': binary})
self._webdriver = webdriver.Firefox(**kwargs)
elif self.browser == 'ie':
if binary:
kwargs.update({'executable_path': binary})
self._webdriver = webdriver.Ie(**kwargs)
elif self.browser == 'edge':
if binary:
kwargs.update({'executable_path': binary})
capabilities = webdriver.DesiredCapabilities.EDGE.copy()
capabilities['acceptSslCerts'] = True
capabilities['javascriptEnabled'] = True
kwargs.update({'capabilities': capabilities})
self._webdriver = webdriver.Edge(**kwargs)
elif self.browser == 'phantomjs':
self._webdriver = webdriver.PhantomJS(
service_args=['--ignore-ssl-errors=true'])
if self._webdriver is None:
raise ValueError(
'"{}" webdriver is not supported. Please use one of {}'
.format(
self.browser,
('chrome', 'firefox', 'ie', 'edge', 'phantomjs')
)
)
self._set_session_cookie()
return self._webdriver