本文整理汇总了Python中selenium.webdriver.common.desired_capabilities.DesiredCapabilities.FIREFOX属性的典型用法代码示例。如果您正苦于以下问题:Python DesiredCapabilities.FIREFOX属性的具体用法?Python DesiredCapabilities.FIREFOX怎么用?Python DesiredCapabilities.FIREFOX使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类selenium.webdriver.common.desired_capabilities.DesiredCapabilities
的用法示例。
在下文中一共展示了DesiredCapabilities.FIREFOX属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_browserstack
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def run_browserstack(self,os_name,os_version,browser,browser_version,remote_project_name,remote_build_name):
"Run the test in browser stack when remote flag is 'Y'"
#Get the browser stack credentials from browser stack credentials file
USERNAME = remote_credentials.USERNAME
PASSWORD = remote_credentials.ACCESS_KEY
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
elif browser.lower() == 'ie':
desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
elif browser.lower() == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
elif browser.lower() == 'opera':
desired_capabilities = DesiredCapabilities.OPERA
elif browser.lower() == 'safari':
desired_capabilities = DesiredCapabilities.SAFARI
desired_capabilities['os'] = os_name
desired_capabilities['os_version'] = os_version
desired_capabilities['browser_version'] = browser_version
if remote_project_name is not None:
desired_capabilities['project'] = remote_project_name
if remote_build_name is not None:
desired_capabilities['build'] = remote_build_name+"_"+str(datetime.now().strftime("%c"))
return webdriver.Remote(RemoteConnection("http://%s:%s@hub-cloud.browserstack.com/wd/hub"%(USERNAME,PASSWORD),resolve_ip= False),
desired_capabilities=desired_capabilities)
示例2: run_sauce_lab
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def run_sauce_lab(self,os_name,os_version,browser,browser_version):
"Run the test in sauce labs when remote flag is 'Y'"
#Get the sauce labs credentials from sauce.credentials file
USERNAME = remote_credentials.USERNAME
PASSWORD = remote_credentials.ACCESS_KEY
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
elif browser.lower() == 'ie':
desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
elif browser.lower() == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
elif browser.lower() == 'opera':
desired_capabilities = DesiredCapabilities.OPERA
elif browser.lower() == 'safari':
desired_capabilities = DesiredCapabilities.SAFARI
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = os_name + ' '+os_version
return webdriver.Remote(command_executor="http://%s:%s@ondemand.saucelabs.com:80/wd/hub"%(USERNAME,PASSWORD),
desired_capabilities= desired_capabilities)
示例3: run_browserstack
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def run_browserstack(self,os_name,os_version,browser,browser_version,remote_project_name,remote_build_name):
"Run the test in browser stack when remote flag is 'Y'"
#Get the browser stack credentials from browser stack credentials file
USERNAME = remote_credentials.USERNAME
PASSWORD = remote_credentials.ACCESS_KEY
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
elif browser.lower() == 'ie':
desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
elif browser.lower() == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
elif browser.lower() == 'opera':
desired_capabilities = DesiredCapabilities.OPERA
elif browser.lower() == 'safari':
desired_capabilities = DesiredCapabilities.SAFARI
desired_capabilities['os'] = os_name
desired_capabilities['os_version'] = os_version
desired_capabilities['browser_version'] = browser_version
if remote_project_name is not None:
desired_capabilities['project'] = remote_project_name
if remote_build_name is not None:
desired_capabilities['build'] = remote_build_name+"_"+str(datetime.now().strftime("%c"))
return webdriver.Remote(RemoteConnection("http://%s:%s@hub-cloud.browserstack.com/wd/hub"%(USERNAME,PASSWORD),resolve_ip= False),
desired_capabilities=desired_capabilities)
示例4: run_sauce_lab
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def run_sauce_lab(self,os_name,os_version,browser,browser_version):
"Run the test in sauce labs when remote flag is 'Y'"
#Get the sauce labs credentials from sauce.credentials file
USERNAME = remote_credentials.USERNAME
PASSWORD = remote_credentials.ACCESS_KEY
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
elif browser.lower() == 'ie':
desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
elif browser.lower() == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
elif browser.lower() == 'opera':
desired_capabilities = DesiredCapabilities.OPERA
elif browser.lower() == 'safari':
desired_capabilities = DesiredCapabilities.SAFARI
desired_capabilities['version'] = browser_version
desired_capabilities['platform'] = os_name + ' '+os_version
return webdriver.Remote(command_executor="http://%s:%s@ondemand.saucelabs.com:80/wd/hub"%(USERNAME,PASSWORD),
desired_capabilities= desired_capabilities)
示例5: _init_caps
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def _init_caps(self):
caps = DesiredCapabilities.FIREFOX
return caps
示例6: create_firefox_driver
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def create_firefox_driver(cls):
"""
Instructions to get this working:
https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
Driver can be found here: https://github.com/mozilla/geckodriver/releases
Important: After downloading the driver, rename it to 'wires' and put it in your path and chmod 755
"""
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities.FIREFOX
cap['marionette'] = True
driver = webdriver.Firefox(capabilities=cap)
driver.implicitly_wait(2)
return driver
示例7: driver
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def driver(self, browser):
self._start_server()
command_executor = 'http://127.0.0.1:4444/wd/hub'
if browser == 'firefox':
return webdriver.Remote(command_executor=command_executor,
desired_capabilities=DesiredCapabilities.FIREFOX)
if browser == 'chrome':
return webdriver.Remote(command_executor=command_executor,
desired_capabilities=DesiredCapabilities.CHROME)
if browser == 'phantom':
return webdriver.PhantomJS()
raise XVEx("{} is not supported on {}".format(browser, self._device.os_name()))
示例8: __init__
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def __init__(self):
try:
self.driver = webdriver.Remote(command_executor='http://firefox:4444/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX)
except URLError as e:
print("Failed to connect!")
raise e
示例9: browser
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def browser(self):
capabilities = self._desired_capabilities
if self._firefox:
capabilities = (capabilities or DesiredCapabilities.FIREFOX).copy()
# Auto-accept unload alerts triggered by navigating away.
if capabilities.get("marionette"):
capabilities["unhandledPromptBehavior"] = "dismiss"
else:
capabilities["unexpectedAlertBehaviour"] = "ignore"
browser = get_browser(self._browser_name, capabilities=capabilities, **self._options)
atexit.register(browser.quit)
return browser
示例10: get
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def get(driverType, localDriver=True, headless=False, path='.'):
driverType = str(driverType)
if driverType == 'PhantomJS':
# phantomjs_options.add_argument("--disable-web-security")
if localDriver:
source = get_source(driverType, path)
driver = webdriver.PhantomJS(executable_path=source, service_log_path=join(path, 'phantomjs.log'), service_args=["--remote-debugger-port=9000", "--web-security=false"])
# driver = webdriver.PhantomJS(executable_path=source, service_args=["--remote-debugger-port=9000", "--web-security=false"])
else:
driver = webdriver.PhantomJS(service_log_path=join(path, 'phantomjs.log'), service_args=["--remote-debugger-port=9000", "--web-security=false"])
# driver = webdriver.PhantomJS(service_args=["--remote-debugger-port=9000", "--web-security=false"])
elif driverType == 'Chrome':
desired = DesiredCapabilities.CHROME
desired['loggingPrefs'] = {'browser': 'ALL'}
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-web-security")
# chrome_options.add_argument("--window-size=800,600")
if headless:
chrome_options.add_argument("--headless") # will not show the Chrome browser window
if localDriver:
source = get_source(driverType, path)
driver = webdriver.Chrome(executable_path=source, service_log_path=join(path, 'chromedriver.log'), desired_capabilities=desired, chrome_options=chrome_options)
else:
driver = webdriver.Chrome(service_log_path=join(path, 'chromedriver.log'), desired_capabilities=desired, chrome_options=chrome_options)
elif driverType == 'Firefox':
# desired = DesiredCapabilities.FIREFOX
# desired['loggingPrefs'] = {'browser': 'ALL'}
firefox_options = Options()
firefox_options.add_argument("--start-maximized")
firefox_options.add_argument("--disable-infobars")
if localDriver:
source = get_source(driverType, path)
driver = webdriver.Firefox(executable_path=source, service_log_path=join(path, 'geckodriver.log'), firefox_options=firefox_options)
else:
driver = webdriver.Firefox(service_log_path=join(path, 'geckodriver.log'), firefox_options=firefox_options)
return driver
示例11: select_browser
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [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")
示例12: get
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def get(driverType, localDriver=True, path='.'):
driverType = str(driverType)
if driverType == 'PhantomJS':
# phantomjs_options.add_argument("--disable-web-security")
if localDriver:
source = get_source(driverType, path)
driver = webdriver.PhantomJS(executable_path=source, service_log_path=join(path, 'phantomjs.log'), service_args=["--remote-debugger-port=9000", "--web-security=false"])
# driver = webdriver.PhantomJS(executable_path=source, service_args=["--remote-debugger-port=9000", "--web-security=false"])
else:
driver = webdriver.PhantomJS(service_log_path=join(path, 'phantomjs.log'), service_args=["--remote-debugger-port=9000", "--web-security=false"])
# driver = webdriver.PhantomJS(service_args=["--remote-debugger-port=9000", "--web-security=false"])
elif driverType == 'Chrome':
desired = DesiredCapabilities.CHROME
desired['loggingPrefs'] = {'browser': 'ALL'}
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-web-security")
# chrome_options.add_argument("--window-size=800,600")
# chrome_options.add_argument("--headless") # will not show the Chrome browser window
if localDriver:
source = get_source(driverType, path)
driver = webdriver.Chrome(executable_path=source, service_log_path=join(path, 'chromedriver.log'), desired_capabilities=desired, chrome_options=chrome_options)
else:
driver = webdriver.Chrome(service_log_path=join(path, 'chromedriver.log'), desired_capabilities=desired, chrome_options=chrome_options)
elif driverType == 'Firefox':
# desired = DesiredCapabilities.FIREFOX
# desired['loggingPrefs'] = {'browser': 'ALL'}
firefox_options = Options()
firefox_options.add_argument("--start-maximized")
firefox_options.add_argument("--disable-infobars")
if localDriver:
source = get_source(driverType, path)
driver = webdriver.Firefox(executable_path=source, service_log_path=join(path, 'geckodriver.log'), firefox_options=firefox_options)
else:
driver = webdriver.Firefox(service_log_path=join(path, 'geckodriver.log'), firefox_options=firefox_options)
return driver
示例13: setUp
# 需要导入模块: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 别名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import FIREFOX [as 别名]
def setUp(self):
self.frontend_config = {
"backend": "remote",
"docker_daemons": [{
"remote_host": "192.168.59.103",
"remote_docker_port": 2375,
"remote_agent_port": 63456
}],
"mongo_opt": {"host": "localhost", "database": "INGIniousFrontendTest"},
"tasks_directory": "./inginious/tasks",
"containers": {
"default": "ingi/inginious-c-default",
"sekexe": "ingi/inginious-c-sekexe",
},
"superadmins": ["test"],
"plugins": [
{
"plugin_module": "inginious.frontend.plugins.auth.demo_auth",
"users": {"test": "test", "test2": "test", "test3": "test"}
}
]
}
if TEST_ENV == "boot2docker":
self.display = None
self.driver = webdriver.Remote(command_executor=(CUSTOM_SELENIUM_EXECUTOR or 'http://192.168.59.103:4444/wd/hub'),
desired_capabilities=DesiredCapabilities.FIREFOX)
self.base_url = CUSTOM_SELENIUM_BASE_URL or "http://192.168.59.3:8081"
self.frontend_host = "192.168.59.3"
self.frontend_port = 8081
self.frontend_ssh_port = 8082
elif TEST_ENV == "boot2docker-local":
self.display = None
self.driver = webdriver.Firefox()
self.base_url = CUSTOM_SELENIUM_BASE_URL or "http://127.0.0.1:8081"
self.frontend_host = "127.0.0.1"
self.frontend_port = 8081
self.frontend_ssh_port = 8082
elif False and TEST_ENV == "jenkins":
self.display = Display(visible=0, size=(1920, 1080))
self.display.start()
self.driver = webdriver.Firefox()
self.base_url = CUSTOM_SELENIUM_BASE_URL or "http://localhost:8081"
self.frontend_host = "localhost"
self.frontend_port = 8081
self.frontend_ssh_port = 8082
self.frontend_config["backend"] = "local"
else:
raise SkipTest("Env variable TEST_ENV is not properly configured. Please take a look a the documentation to properly configure your "
"test environment.")
self.driver.maximize_window()
self.driver.implicitly_wait(30)
self.verificationErrors = []
self.accept_next_alert = True
_drop_database(self.frontend_config["mongo_opt"])
self.frontend_thread, self.frontend_server, self.close_app_func = _start_frontend(self.frontend_config,
self.frontend_host,
self.frontend_port,
self.frontend_ssh_port)