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


Python Options.binary_location方法代码示例

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


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

示例1: loginToInterface

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
def loginToInterface(isMac, chrome, driver, host, port=8686, username='admin', password='[email protected]#123'):
    logCommon.info('Will start web browser and perform test case.')
    chromeDriver = os.path.normpath(driver)
    logCommon.info('Browser driver path: ' + str(chromeDriver))
    os.environ["webdriver.chrome.driver"] = chromeDriver
    opts = Options()
    if (not isMac):
        opts = Options()
        opts.binary_location = os.path.normpath(chrome)
    else:
        opts.add_argument("--start-maximized")
    driver = webdriver.Chrome(chromeDriver, chrome_options=opts)
    # options.add_argument("--start-maximized")
    # driver.set_window_size(1024, 600)
    driver.maximize_window()
    # go to the google home page
    index = 'http://' + str(host) + ':' + str(port) + '/XOAM/login/index.html'
    logCommon.info('Web page: ' + str(index))
    driver.get(index)
    driver.find_element_by_id('loginUsername').clear()
    driver.find_element_by_id('loginUsername').send_keys(username)
    driver.find_element_by_id('loginPassword').clear()
    driver.find_element_by_id('loginPassword').send_keys(password)
    driver.find_element_by_id('submit').click()
    try:
        WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "ebBtnSearch")))
        logCommon.info('Login to the InterfaceManagement page successfully.')
    except Exception as e:
        logCommon.error('Login to the InterfaceManagement page failed.')
        return False
    return driver
开发者ID:hahakiki2010,项目名称:selenium,代码行数:33,代码来源:CommonFunc.py

示例2: makeConnection

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
def makeConnection(SERVER, USER, PASSWORD):
    url = 'https://'+SERVER+'/'

    chrome_options = Options() 
    chrome_options.add_argument("--headless") 
    chrome_options.binary_location = '/usr/bin/chromium-browser' 
    driver = webdriver.Chrome(executable_path= os.path.expanduser('~/usr/local/bin/chromedriver') , chrome_options=chrome_options) 
    driver.get(url)
    time.sleep(1)
    driver.save_screenshot(os.path.join(os.path.dirname(os.path.realpath(__file__)), '/tmp', 'kk1.png'))


    elemU = driver.find_element_by_name("username")
    #while elemU:
    print("Identifying...")
    elemP = driver.find_element_by_name("password")
    elemU.clear()
    elemU.send_keys(USER)
    elemP.clear()
    elemP.send_keys(PASSWORD)

    driver.save_screenshot(os.path.join(os.path.dirname(os.path.realpath(__file__)), '/tmp', 'kk2.png'))

    elemP.send_keys(Keys.RETURN) 
    time.sleep(1)
    #    try: 
    #        elemU = driver.find_element_by_name("username").clear()
    #    except: 
    #        elemU = None

    driver.save_screenshot(os.path.join(os.path.dirname(os.path.realpath(__file__)), '/tmp', 'kk3.png'))

    return driver
开发者ID:fernand0,项目名称:scripts,代码行数:35,代码来源:manageRedirisSpam.py

示例3: setUp

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
    def setUp(self):

        chromium_path = '/usr/bin/chromium'
        chromedriver_path = './chromedriver'
        
        opts = Options()
        opts.binary_location = chromium_path
        opts.add_experimental_option("prefs", {
            "download.default_directory": "./test_downloaded", 
            "helperApps.neverAsk.saveToDisk": "octet/stream", 
            "directory_upgrade": True,
            "profile": {"default_content_settings": {"multiple-automatic-downloads": 1}}
            })
        
        self.driver = webdriver.Chrome(chrome_options=opts, executable_path=chromedriver_path)

        #self.driver = webdriver.Firefox()        
        url = os.getenv('TEST_URL', config.url)
        self.driver.get(url)

        self.__load_pages()

        # Sets up by redirecting to login page
        main_page = page.MainPage(self.driver)
        main_page.click_login_link()
开发者ID:elec-otago,项目名称:agbase,代码行数:27,代码来源:end_to_end_test.py

示例4: launch_browser

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
def launch_browser():

    if env.RUNNING_BROWSER.upper() == "FIREFOX":
        # the end of the browser process , the end of the browser driven process
        os.popen("TASKKILL /F /IM firefoxdriver.exe")

        fp = FirefoxProfile()
        fp.native_events_enabled = False

        binary_path = PublicImp.common.get_value_from_conf("FIREFOX_BINARY_PATH")

        if binary_path == "":
            env.driver = selenium.webdriver.Firefox(firefox_profile=fp)
        else:
            fb = FirefoxBinary(firefox_path=binary_path)
            env.driver = selenium.webdriver.Firefox(firefox_profile=fp, firefox_binary=fb)

    elif env.RUNNING_BROWSER.upper() == "CHROME":
        os.popen("TASKKILL /F /IM chromedriver.exe")

        binary_path = PublicImp.common.get_value_from_conf("CHROME_BINARY_PATH")
        chromedriver = PublicImp.common.get_value_from_conf("DRIVER_CHROME")

        if binary_path == "":
            os.environ["webdriver.chrome.driver"] = chromedriver
            env.driver = selenium.webdriver.Chrome(executable_path=chromedriver)
        else:
            opts = Options()
            opts.binary_location = binary_path
            os.environ["webdriver.chrome.driver"] = chromedriver
            env.driver = selenium.webdriver.Chrome(executable_path=chromedriver, chrome_options=opts)

    elif env.RUNNING_BROWSER.upper() == "IE":
        os.popen("TASKKILL /F /IM IEDriverServer.exe")

        dc = DesiredCapabilities.INTERNETEXPLORER.copy()

        dc['acceptSslCerts'] = True
        dc['nativeEvents'] = True

        iedriver = PublicImp.common.get_value_from_conf("DRIVER_IE")
        os.environ["webdriver.ie.driver"] = iedriver
        env.driver = selenium.webdriver.Ie(executable_path=iedriver, capabilities=dc)

    else:
        return False

    env.platformName = env.RUNNING_BROWSER

    env.TEST_URL = PublicImp.common.get_value_from_conf("TESTING_URL")
    env.driver.get(env.TEST_URL)
    env.driver.maximize_window()

    time.sleep(3)
    env.driver.refresh()
    # env.driver.set_window_size(480, 800)
    time.sleep(3)

    return True
开发者ID:yzwy1988,项目名称:YOHO_Automated_Test,代码行数:61,代码来源:executer.py

示例5: launch_webdriver

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
    def launch_webdriver(self):
        options = Options()
        options.binary_location = ''
        options.debugger_address = '{}:{}'.format(
            DEFAULT_WEBVIEW_INSPECTOR_IP,
            DEFAULT_WEBVIEW_INSPECTOR_PORT)

        self.driver = webdriver.Chrome(
            executable_path=CHROMEDRIVER_EXEC_PATH,
            chrome_options=options)

        self.assertThat(self.driver, NotEquals(None))
开发者ID:Pooler22,项目名称:CalendarHTML5,代码行数:14,代码来源:__init__.py

示例6: setUpClass

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
 def setUpClass(cls):
   if not os.path.isfile(PATH_TO_CHROME):
     raise Exception("No Chrome binary at '" + PATH_TO_CHROME + "'. "
                     "Set PATH_TO_CHROME.")
   if not os.path.isfile(PATH_TO_CHROMEDRIVER):
     raise Exception("No Chrome Driver binary at '" +
                     PATH_TO_CHROMEDRIVER + "'."
                     "Set PATH_TO_CHROMEDRIVER.")
   options = Options()
   options.binary_location = PATH_TO_CHROME
   FormClassificationTest.driver = webdriver.Chrome(PATH_TO_CHROMEDRIVER,
                                                    chrome_options=options)
开发者ID:LoveItachi,项目名称:chromium-crosswalk,代码行数:14,代码来源:form_classification_test.py

示例7: __init__

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
  def __init__(self, chrome_path, chromedriver_path, profile_path,
               passwords_path, enable_automatic_password_saving):
    """Creates a new testing Environment, starts Chromedriver.

    Args:
      chrome_path: The chrome binary file.
      chromedriver_path: The chromedriver binary file.
      profile_path: The chrome testing profile folder.
      passwords_path: The usernames and passwords file.
      enable_automatic_password_saving: If True, the passwords are going to be
          saved without showing the prompt.

    Raises:
      IOError: When the passwords file cannot be accessed.
      ParseError: When the passwords file cannot be parsed.
      Exception: An exception is raised if |profile_path| folder could not be
      removed.
    """

    # Cleaning the chrome testing profile folder.
    if os.path.exists(profile_path):
      shutil.rmtree(profile_path)

    options = Options()
    if enable_automatic_password_saving:
      options.add_argument("enable-automatic-password-saving")
    # TODO(vabr): show_prompt is used in WebsiteTest for asserting that
    # Chrome set-up corresponds to the test type. Remove that knowledge
    # about Environment from the WebsiteTest.
    self.show_prompt = not enable_automatic_password_saving
    options.binary_location = chrome_path
    options.add_argument("user-data-dir=%s" % profile_path)

    # The webdriver. It's possible to choose the port the service is going to
    # run on. If it's left to 0, a free port will be found.
    self.driver = webdriver.Chrome(chromedriver_path, 0, options)

    # Password internals page tab/window handle.
    self.internals_window = self.driver.current_window_handle

    # An xml tree filled with logins and passwords.
    self.passwords_tree = ElementTree.parse(passwords_path).getroot()

    self.website_window = self._OpenNewTab()

    self.websitetests = []

    # Map messages to the number of their appearance in the log.
    self.message_count = { MESSAGE_ASK: 0, MESSAGE_SAVE: 0 }

    # A list of (test_name, test_type, test_success, failure_log).
    self.tests_results = []
开发者ID:Connlaio,项目名称:chromium,代码行数:54,代码来源:environment.py

示例8: get_chrome_driver

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
 def get_chrome_driver(self):
     """Setup and return a Chrom[e|ium] browser for Selenium."""
     opts = Options()
     absp = os.path.abspath
     if "TRAVIS" in os.environ:  # github.com/travis-ci/travis-ci/issues/938
         opts.add_argument("--no-sandbox")
     opts.add_extension(self.pb_ext_path)  # will fail if ext can't be found
     if self.browser_bin:  # otherwise will use webdriver's default binary
         print "Browser binary:", absp(self.browser_bin)
         opts.binary_location = self.browser_bin  # set binary location
     # Fix for https://code.google.com/p/chromedriver/issues/detail?id=799
     opts.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
     return webdriver.Chrome(chrome_options=opts)
开发者ID:PollyP,项目名称:privacybadgerchrome,代码行数:15,代码来源:pbtest.py

示例9: get_a_chrome_headless_driver

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
def get_a_chrome_headless_driver():
    from selenium.webdriver.chrome.options import Options

    CHROME_PATH = '/usr/bin/google-chrome-stable'
    CHROMEDRIVER_PATH = '/home/user/bin/chromedriver'
    WINDOW_SIZE = "1920,1080"

    opts = Options()
    opts.add_argument("--headless")
    opts.add_argument("--window-size=%s" % WINDOW_SIZE)
    opts.binary_location = CHROME_PATH

    driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=opts)
    return driver
开发者ID:ecktom,项目名称:docker-selenium,代码行数:16,代码来源:python_test.py

示例10: before_all

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
def before_all(context):
    benv.before_all(context)
    context.screenshots_dir = os.environ.get('SANITYSCREENSHOTDIR')
    context.default_browser = os.environ.get('SANITYBROWSER', '')
    if context.default_browser.lower() == 'chrome_headless':
        context.default_browser = 'chrome'
        options = Options()
        options.binary_location = '/usr/bin/google-chrome'
        options.add_argument('--headless')
        options.add_argument('--disable-gpu')
        context.browser_args = {
            'options': options,
        }
    context.base_url = get_base_url(os.environ['SANITYURL'])
开发者ID:cyverse,项目名称:operation-sanity,代码行数:16,代码来源:environment.py

示例11: create

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
def create(url):
    options = Options()
    options.binary_location = CHROME
    options.add_argument('--headless')
    options.add_argument('--disable-gpu')
    options.add_argument('--ignore-certificate-errors')
    options.add_argument('--allow-running-insecure-content')
    options.add_argument('--disable-web-security')
    options.add_argument('--lang=ja')
    options.add_argument('--blink-settings=imagesEnabled=false')
    driver = webdriver.Chrome(chrome_options=options)
    driver.get(url)
    driver_wait = WebDriverWait(driver, 10)
    driver_wait.until(ec.presence_of_all_elements_located)
    return driver
开发者ID:takeknock,项目名称:pp,代码行数:17,代码来源:driver_factory.py

示例12: chrome_manager

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
    def chrome_manager(self):
        opts = Options()
        if self.on_travis:  # github.com/travis-ci/travis-ci/issues/938
            opts.add_argument("--no-sandbox")
        opts.add_extension(self.extension_path)
        opts.binary_location = self.browser_path
        opts.add_experimental_option("prefs", {"profile.block_third_party_cookies": False})

        caps = DesiredCapabilities.CHROME.copy()

        driver = webdriver.Chrome(chrome_options=opts, desired_capabilities=caps)
        try:
            yield driver
        finally:
            driver.quit()
开发者ID:sampablokuper,项目名称:https-everywhere,代码行数:17,代码来源:shim.py

示例13: _get_driver

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
  def _get_driver(self, user_data_dir, profile_name=None, chrome_binary=None,
                  chromedriver_binary='chromedriver'):
    """Spin up a ChromeDriver instance that uses a given set of user data.

    Generates a temporary profile data directory using a local set of test data.

    Args:
      user_data_dir: Path string for the writable directory in which profiles
        should be stored.
      profile_name: Name of the profile data directory to be created/used in
        user_data_dir.

        If None then an eight character name will be generated randomly.

        This directory will be removed after the task flow completes.
      chrome_binary: Path string to the Chrome binary that should be used by
        ChromeDriver.

        If None then it will use the PATH to find a binary.

    Returns: The generated Chrome Driver instance.
    """
    options = Options()

    if profile_name is None:
      profile_name = ''.join(choice(ascii_lowercase) for i in range(8))

    options.add_argument('--profile-directory=%s' % profile_name)

    full_path = os.path.realpath(__file__)
    path, filename = os.path.split(full_path)
    profile_dir_src = os.path.join(path, 'testdata', 'Default')
    self._profile_dir_dst = os.path.join(user_data_dir, profile_name)
    self._copy_tree(profile_dir_src, self._profile_dir_dst)

    if chrome_binary is not None:
      options.binary_location = chrome_binary

    options.add_argument('--user-data-dir=%s' % user_data_dir)
    options.add_argument('--show-autofill-type-predictions')

    service_args = []

    driver = webdriver.Chrome(executable_path=chromedriver_binary,
                              chrome_options=options,
                              service_args=service_args)
    driver.set_page_load_timeout(15)  # seconds
    return driver
开发者ID:Samsung,项目名称:ChromiumGStreamerBackend,代码行数:50,代码来源:task_flow.py

示例14: start

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
    def start(self):
        if self.engine == 'chrome':
            from selenium.webdriver.chrome.options import Options
            options = Options()

            options.set_headless(headless=True)
            options.add_argument('--disable-gpu')
            options.add_argument('--log-level=3')
            options.add_argument('--mute-audio')
            options.add_experimental_option('prefs', {
                'profile.managed_default_content_settings.images': 2,
            })
            options.binary_location = self.binary_path

            driver = webdriver.Chrome(
                chrome_options=options,
                executable_path=self.driver_path,
            )

        elif self.engine == 'firefox':
            from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
            from selenium.webdriver.firefox.options import Options

            options = Options()
            options.set_headless(headless=True)
            options.add_argument('--disable-gpu')

            profile = webdriver.FirefoxProfile()
            profile.set_preference('permissions.default.image', 2)
            profile.set_preference('media.volume_scale', '0.0')
            profile.set_preference('media.autoplay.enabled', False)

            binary = FirefoxBinary(self.binary_path)
            driver = webdriver.Firefox(
                firefox_profile=profile,
                firefox_options=options,
                firefox_binary=binary,
                executable_path=self.driver_path,
                log_file=os.devnull,
            )

        driver.set_window_size(1920, 1080)
        self.driver = driver
开发者ID:altbdoor,项目名称:tweet-media-archive,代码行数:45,代码来源:extended.py

示例15: add_options

# 需要导入模块: from selenium.webdriver.chrome.options import Options [as 别名]
# 或者: from selenium.webdriver.chrome.options.Options import binary_location [as 别名]
    def add_options(self, chromiumlike, cache_state):
        ''' Sets a bunch of cmd switches and options passed to selenium'''

        mode = "chromiumlike" if chromiumlike else "sparrow"

        driver_options = Options()

        # Field Trial
        if chromiumlike:
            driver_options.add_argument('--sparrow-force-fieldtrial=chromiumlike')
            driver_options.add_argument('--user-agent=%s' % self.user_agent)
            driver_options.add_argument('--user-data-dir=%s' % self.chromiumlike_user_data_dir)

        else:
            driver_options.add_argument('--sparrow-force-fieldtrial')
            driver_options.add_argument('--user-data-dir=%s' % self.sparrow_user_data_dir)
            for switch in self.sparrow_only_switches:
                driver_options.add_argument(switch)
                logging.debug("Adding switch to sparrow only: %s" % switch)

        # Passed from config file
        for switch in self.common_switches:
            driver_options.add_argument(switch)
            logging.debug("Adding switch: %s" % switch)

        if self.ublock_path:
            if not os.path.exists(self.ublock_path):
                print("Error, ublock crx file not found.")
                sys.exit(1)

            driver_options.add_extension(self.ublock_path)

        # Test label
        test_label_entry = "--beer-test-label=%s-%s-%s-%s-%s-%s" % (self.test_label_prefix, self.chromium_version,
                                                                    sys.platform, mode, cache_state, self.test_start_time)
        driver_options.add_argument(test_label_entry)
        logging.info(test_label_entry)

        driver_options.binary_location = self.binary_location
        driver_options.to_capabilities()['loggingPrefs'] = { 'browser':'ALL' }

        return driver_options
开发者ID:bizzbyster,项目名称:bizzbyster.github.io,代码行数:44,代码来源:drive.py


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