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


Python DesiredCapabilities.CHROME屬性代碼示例

本文整理匯總了Python中selenium.webdriver.common.desired_capabilities.DesiredCapabilities.CHROME屬性的典型用法代碼示例。如果您正苦於以下問題:Python DesiredCapabilities.CHROME屬性的具體用法?Python DesiredCapabilities.CHROME怎麽用?Python DesiredCapabilities.CHROME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在selenium.webdriver.common.desired_capabilities.DesiredCapabilities的用法示例。


在下文中一共展示了DesiredCapabilities.CHROME屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_browserstack

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [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 CHROME [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 CHROME [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 CHROME [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: get_browser

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
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 
開發者ID:materialsproject,項目名稱:MPContribs,代碼行數:17,代碼來源:views.py

示例6: test_create_remote_driver_chrome

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
def test_create_remote_driver_chrome(webdriver_mock, config):
    config.set('Driver', 'type', 'chrome')
    server_url = 'http://10.20.30.40:5555'
    utils = mock.MagicMock()
    utils.get_server_url.return_value = server_url
    config_driver = ConfigDriver(config, utils)

    # Chrome options mock
    chrome_options = mock.MagicMock()
    chrome_options.to_capabilities.return_value = {'goog:chromeOptions': 'chrome options'}
    config_driver._create_chrome_options = mock.MagicMock(return_value=chrome_options)

    config_driver._create_remote_driver()
    capabilities = DesiredCapabilities.CHROME.copy()
    capabilities['goog:chromeOptions'] = 'chrome options'
    webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,
                                                  desired_capabilities=capabilities) 
開發者ID:Telefonica,項目名稱:toolium,代碼行數:19,代碼來源:test_config_driver.py

示例7: test_create_remote_driver_chrome_old_selenium

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
def test_create_remote_driver_chrome_old_selenium(webdriver_mock, config):
    config.set('Driver', 'type', 'chrome')
    server_url = 'http://10.20.30.40:5555'
    utils = mock.MagicMock()
    utils.get_server_url.return_value = server_url
    config_driver = ConfigDriver(config, utils)

    # Chrome options mock
    chrome_options = mock.MagicMock()
    chrome_options.to_capabilities.return_value = {'chromeOptions': 'chrome options'}
    config_driver._create_chrome_options = mock.MagicMock(return_value=chrome_options)

    config_driver._create_remote_driver()
    capabilities = DesiredCapabilities.CHROME.copy()
    capabilities['chromeOptions'] = 'chrome options'
    webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,
                                                  desired_capabilities=capabilities) 
開發者ID:Telefonica,項目名稱:toolium,代碼行數:19,代碼來源:test_config_driver.py

示例8: driver

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
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() 
開發者ID:jberghoef,項目名稱:wagtail-tag-manager,代碼行數:18,代碼來源:fixtures.py

示例9: remote

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
def remote(self) -> None:
        if not self.debug:
            log("debug mode is turned off, can't reuse old session")
            return

        file = open(self.current_session_path, "r")
        content = file.read()
        lines = content.split(";")
        url = lines[0]
        session = lines[1]

        self.driver = webdriver.Remote(
            command_executor=url, desired_capabilities=DesiredCapabilities.CHROME
        )
        self.driver.session_id = session

        self.set_config() 
開發者ID:breuerfelix,項目名稱:king-bot,代碼行數:19,代碼來源:custom_driver.py

示例10: test_create_local_driver_chrome

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
def test_create_local_driver_chrome(webdriver_mock, config):
    config.set('Driver', 'type', 'chrome')
    config.set('Driver', 'chrome_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)
    config_driver._create_chrome_options = lambda: 'chrome options'

    config_driver._create_local_driver()
    webdriver_mock.Chrome.assert_called_once_with('/tmp/driver', desired_capabilities=DesiredCapabilities.CHROME,
                                                  chrome_options='chrome options') 
開發者ID:Telefonica,項目名稱:toolium,代碼行數:11,代碼來源:test_config_driver.py

示例11: __init__

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
def __init__(self):
        self.remote =  "http://selenium:4444/wd/hub"
        self.browser_type = DesiredCapabilities.CHROME

        self.browser = None 
開發者ID:rikonor,項目名稱:vanguard-api,代碼行數:7,代碼來源:browser.py

示例12: run_selenium

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
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 
開發者ID:wcrasta,項目名稱:ESPN-Fantasy-Basketball,代碼行數:31,代碼來源:app.py

示例13: init_browser

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
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) 
開發者ID:jberghoef,項目名稱:wagtail-tag-manager,代碼行數:16,代碼來源:webdriver.py

示例14: setUp

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
def setUp(self):
        self.driver = webdriver.Remote(
            command_executor="http://127.0.0.1:4444/wd/hub",
            desired_capabilities=DesiredCapabilities.CHROME
        ) 
開發者ID:small99,項目名稱:DevAuto,代碼行數:7,代碼來源:2.3_remote_sample.py

示例15: _init_caps

# 需要導入模塊: from selenium.webdriver.common.desired_capabilities import DesiredCapabilities [as 別名]
# 或者: from selenium.webdriver.common.desired_capabilities.DesiredCapabilities import CHROME [as 別名]
def _init_caps(self):
        caps = DesiredCapabilities.CHROME

        if self.readlog:
            caps['loggingPrefs'] = {'performance': 'ALL'}
            caps['chromeOptions'] = {'perfLoggingPrefs': {'enableTimeline': False, 'enablePage': False}}

        return caps 
開發者ID:ikreymer,項目名稱:browsertrix,代碼行數:10,代碼來源:browser.py


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