The use of different webdriver in the selenium may have different methods, and some of the same operations will result in differing results.
This article is mainly about how chrome () is used.
Other webdriver can refer to the official documentation
Chrome Webdriver Options
Brief introduction
This is a Chrome parameter object, and this object uses the Add_argument () method to add a startup parameter,
Once added, you can pass this options object in when initializing the Wedriver object, and the 921 implementation takes his specific
The parameter starts with ChromE.
such as the following example
fromSeleniumImportWebdriver fromSelenium.webdriver.chrome.optionsImportOptions#instantiate a startup Parameter objectChrome_options = Options()#set browser window sizeChrome_options.add_argument('--window-size=1366,768')#Launch BrowserBrowser = Webdriver.Chrome(chrome_options=chrome_options)#Request Baidu HomepageBrowser.Get('http://www.baidu.com')
Where '--window-size=1366,7668 ' is a startup key parameter
The common startup key parameters are as follows
| Startup Parameters |
function |
| --user-agent= "" |
Set the user-agent of the request header |
| --window-size=1366,768 |
Set Browser resolution (window size) |
| --headless |
No interface to run (no window) |
| --start-maximized |
Maximize run (full screen window) |
| --incognito |
Stealth mode (no Trace mode) |
| --disable-javascript |
Disable JavaScript |
| --disable-infobars |
Disable the prompt that the browser is being programmed by automation |
The last '--disable-infobars ', meaning this
If you do not set this parameter, the browser opens with such a prompt box
Set this parameter to cancel this hint
The full startup parameters can be viewed on this page:
https://peter.sh/experiments/chromium-command-line-switches /
There are several ways to do this:
Disable picture loading
Prefs = { 'profile.default_content_setting_values' : { ' images' : 2 }}chrome_options. add_experimental_option ('prefs', prefs)
Disable browser pop-up windows
Prefs = { 'profile.default_content_setting_values' : { ' Notifications ' : 2 } } options. Add_experimental_option('prefs'
Note that these are also startup parameters, to be written in browser = Webdriver. Before Chrome (chrome_options=chrome_options)
Selenium Startup Item Options