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-8from Selenium Import webdriveroption = Webdriver. Chromeoptions () option.add_argument ('--user-data-dir=c:\users\administrator\appdata\local\google\chrome\user Data ') #设置成用户自己的数据目录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-8from Selenium Import webdriveroption = 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-8from Selenium Import webdriveroption = 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.
Below are some of the configuration information collected:
Some chrome's address bar commands (these commands are constantly changing, all of which are not necessarily useful)
Enter the following command in Chrome's browser address bar to return the corresponding results. These commands include viewing memory status, browser status, network status, DNS server status, plugin caching, and so on.
About:version-Show Current version
About:memory-Show native browser memory usage
About:plugins-Show Installed plugins
About:histograms-Show History
About:dns-Show DNS status
About:cache-Show Cache page
ABOUT:GPU-whether there is hardware acceleration
About:flags-Open Some plugins//use after the pop-up stuff: "Please be careful, these experiments may be risky", I do not know will not mess with my configuration Ah!
chrome://extensions/-View the extensions that have been installed
Some of the other useful parameters for chrome and a brief Chinese note (using the same method, of course, can also be used in the shell)
–user-data-dir= "[PATH]" Specifies the user folder users data path, which can be stored in a bookmark such as a partition other than the system partition.
–disk-cache-dir= "[PATH]" specifies the cache path
–disk-cache-size= Specifies the cache size, in units of byte
–first run resets to its initial state, first run
–incognito Stealth Mode Boot
–disable-javascript disabling JavaScript
--omnibox-popup-count= "num" Changes the number of prompt menus that pop up in the address bar to Num. I've changed to 15.
--user-agent= "xxxxxxxx" modifies the agent string of the HTTP request header, you can view the effect of the modification by About:version page
--disable-plugins prohibit loading all plugins, can increase the speed. You can view the effects from the About:plugins page
--disable-javascript disable JavaScript, if you feel slow to add this
--disable-java disabling Java
--start-maximized start-up is maximized
--no-sandbox Canceling sandbox mode
--single-process Single-Process operation
--process-per-tab each label using a separate process
--process-per-site Each site uses a separate process
--in-process-plugins plugin does not enable separate processes
--disable-popup-blocking disable pop-up blocking
--disable-plugins Disabling plugins
--disable-images Disabling images
--incognito Boot into stealth mode
--enable-udd-profiles Enable account Switching menu
--proxy-pac-url using PAC proxy [via 1/2]
--LANG=ZH-CN set language to Simplified Chinese
--disk-cache-dir Custom Cache Directory
--disk-cache-size Custom Cache maximum value (in bytes)
--media-cache-size Custom Multimedia cache maximum (in bytes)
--bookmark-menu Add a Bookmark button to the toolbar
--enable-sync Enable bookmark synchronization
Selenium loading a user profile when you start chrome