Selenium Startup Item Options

Source: Internet
Author: User

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

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.