Webdriver loading a configuration when you start Chrome

Source: Internet
Author: User

Selenium Operation Browser is not loaded any configuration, online search for half a day, about the Firefox load configuration multipoint, chrome data is very few, here is about loading Chrome configuration method:
First, load all chrome configurations
Use the Chrome address bar to enter chrome://version/, view your profile path, and then, when the browser starts, call this configuration file with the following code:
#coding =utf-8
From selenium import Webdriver
option = Webdriver. Chromeoptions ()
Option.add_argument ('--user-data-dir=c:\users\administrator\appdata\local\google\chrome\user data ') # Set as user's own data directory
Driver = Webdriver. Chrome (chrome_options=option)


Second, modify the browser's user-agent to disguise your browser to access the mobile m station
#coding =utf-8
From selenium import Webdriver
option = Webdriver. Chromeoptions ()
Option.add_argument ('--user-agent=iphone ')
Driver = Webdriver. Chrome (chrome_options=option)
Driver.get (' http://www.taobao.com/')


Third, install CRX extension when browser starts
#coding =utf-8
From selenium import Webdriver
option = Webdriver. Chromeoptions ()
Option.add_extension (' D:\crx\AdBlock_v2.17.crx ') #自己下载的crx路径
Driver = Webdriver. Chrome (chrome_options=option)
Driver.get (' http://www.taobao.com/')
  You can go to https://sites.google.com/a/chromium.org/chromedriver/capabilities to see more, or go to http://stackoverflow.com/to find.

Webdriver loading a configuration when you start Chrome

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.