當前位置: 首頁>>代碼示例>>Python>>正文


Python DesiredCapabilities.FIREFOX屬性代碼示例

本文整理匯總了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) 
開發者ID:qxf2,項目名稱:makemework,代碼行數:27,代碼來源:DriverFactory.py

示例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) 
開發者ID:qxf2,項目名稱:makemework,代碼行數:23,代碼來源:DriverFactory.py

示例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) 
開發者ID:qxf2,項目名稱:qxf2-page-object-model,代碼行數:27,代碼來源:DriverFactory.py

示例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) 
開發者ID:qxf2,項目名稱:qxf2-page-object-model,代碼行數:23,代碼來源:DriverFactory.py

示例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 
開發者ID:ikreymer,項目名稱:browsertrix,代碼行數:5,代碼來源:browser.py

示例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 
開發者ID:idaholab,項目名稱:civet,代碼行數:15,代碼來源:SeleniumTester.py

示例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())) 
開發者ID:expressvpn,項目名稱:expressvpn_leak_testing,代碼行數:15,代碼來源:webdriver.py

示例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 
開發者ID:salesforce,項目名稱:AutoTriageBot,代碼行數:9,代碼來源:SeleniumDrivers.py

示例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 
開發者ID:elliterate,項目名稱:capybara.py,代碼行數:16,代碼來源:driver.py

示例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 
開發者ID:elvisyjlin,項目名稱:lf2gym,代碼行數:40,代碼來源:seleniumdriver.py

示例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") 
開發者ID:fireeye,項目名稱:ReelPhish,代碼行數:43,代碼來源:ReelPhish.py

示例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 
開發者ID:elvisyjlin,項目名稱:media-scraper,代碼行數:39,代碼來源:seleniumdriver.py

示例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) 
開發者ID:UCL-INGI,項目名稱:INGInious,代碼行數:62,代碼來源:SeleniumTest.py


注:本文中的selenium.webdriver.common.desired_capabilities.DesiredCapabilities.FIREFOX屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。