• Selenium Video Tutorials

Chrome WebDriver Options



Selenium Chrome webdriver Options are handled with the class - selenium.webdriver.chrome.options.Options.

Methods

Some of the methods of the above mentioned class are listed below −

  • add_argument(args) − It is used to append arguments to a list.

  • add_encoded_extension(ext) −It is used to append base 64 encoded string and the extension data to a list that will be utilised to get it to the ChromeDriver.

  • add_experimental_option(n, val) − It is used to append an experimental option which is passed to the Chrome browser.

  • add_extension(ext) − It is used to append the extension path to a list that will be utilised to get it to the ChromeDriver.

  • set_capability(n, val) − It is used to define a capability.

  • to_capabilities(n, val) − It is used to generate capabilities along with options and yields a dictionary with all the data.

  • arguments −It is used to yield arguments list required for the browser.

  • binary_location − It is used to obtain the binary location. If there is no path, an empty string is returned.

  • debugger_address − It is used to yield the remote devtools object.

experimental_options − It is used to yield a dictionary of the Chrome experimental options.

  • extensions − It is used to yield an extensions list which shall be loaded to the Chrome browser.

  • headless −It is used to check if the headless argument is set or not.

Code Implementation

The code implementation for the Selenium Chrome Webdriver options is as follows −

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
#object of Options class
c = Options()
#passing headless parameter
c.add_argument("--headless")
#adding headless parameter to webdriver object
driver = webdriver.Chrome(executable_path='../drivers/chromedriver', options=c)
# implicit wait time
driver.implicitly_wait(5)
# url launch
driver.get("https −//www.tutorialspoint.com/about/about_careers.htm")
print('Page title − ' + driver.title)
# driver quit
driver.quit()

Output

Careers

The output shows the message - Process with exit code 0 meaning that the above Python code executed successfully. Also, the page title of the application(obtained from the driver.title method) - About Careers at Tutorials Point - Tutorialspoint gets printed in the console.

Advertisements