Seenium Start Chrome Configuration Parameters Problem

Every time selenium starts chrome browser, Chrome browser is clean, no plug-ins, no collection, no history. This is because selenium starts a naked browser to ensure the fastest running efficiency when starting chrome. That's why it needs to configure parameters, but sometimes we need more than a naked browser.

The selenium startup configuration parameter receives the ChromeOptions class in the following way:

from selenium import webdriver
option = webdriver.ChromeOptions()

After you create the ChromeOptions class, you add parameters. There are several specific ways to add parameters, which correspond to adding different types of configuration items.

Setting chrome binary location

from selenium import webdriver
option = webdriver.ChromeOptions()

# Add startup parameters

# Adding Extended Applications

# Adding experimental settings

# Setting debugger address

Common configuration parameters:

from selenium import webdriver
option = webdriver.ChromeOptions()

#Add UA
options.add_argument('user-agent="MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"')

#Specify browser resolution

#Google Documents mentions the need to add this attribute to avoid bug s

 #Hide scrollbars for special pages

#Increase speed without loading pictures

#Browsers do not provide visual pages. If the system does not support visualization without this, it will fail to start under linux

#Running with the highest privileges

#Manually specify the browser location to use
options.binary_location = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 

#Add crx plug-ins

#Disable JavaScript

#Set the developer mode to start, in which the webdriver attribute is a normal value
options.add_experimental_option('excludeSwitches', ['enable-automation']) 

#Disable Browser Bullet Window
prefs = {  
    'profile.default_content_setting_values' :  {  
        'notifications' : 2  


Browser Address Bar Parameters:

Enter the following commands in the browser address bar to get the corresponding information

about:version - Display the current version

about:memory - Display local browser memory usage

about:plugins - Display installed plug-ins

about:histograms - Display history

about:dns - display DNS state

about:cache - Display cached pages

about:gpu -Is there hardware acceleration?

chrome://Extensions / View the installed extensions

Other configuration project parameters

# Specify the user folder User Data path to save user data such as bookmarks in partitions other than system partitions

# Specify Cache path

# Specify the Cache size in Byte

–first run 
# Reset to the initial state, first run

# Stealth mode startup

# Disable Javascript

# Change the number of prompt menus that pop up in the address bar to num

# Modify the Agent string in the HTTP request header to view the modification effect through the about:version page

# Disabling all plug-ins can increase speed. You can view the effect through the about:plugins page

# Disable JavaScript if it feels slow and add this

# Disable java

# Maximize startup

# Cancel Sandbox Mode

# Single Process Running

# Each tag uses a separate process

# Each site uses a separate process

# Plug-ins do not enable separate processes

# Disabling ejection interception

# Disable plug-ins

# Disable images

# Start into stealth mode

# Enable account switching menu

# Using pac proxy [via 1/2]

# Setting Language to Simplified Chinese

# Custom Cache Directory

# Custom cache maximum (unit byte)

# Custom Multimedia Cache Maximum (Unit byte)

# Add a bookmark button to the toolbar

# Enable bookmark synchronization

Keywords: Javascript Selenium Linux Google

Added by eruiz1973 on Tue, 14 May 2019 21:25:04 +0300