Chrome WebDriver Options

Selenium Chrome webdriver Options are handled with the class - selenium.webdriver.chrome.options.Options.
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_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_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_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.
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.
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.
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.
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.
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.
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.
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.
headless −It is used to check if the headless argument is set or not.
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()
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.

    46 Lectures 
     5.5 hours 

 Aditya Dua

    296 Lectures 
     146 hours 

 Arun Motoori

    411 Lectures 
     38.5 hours 

 In28Minutes Official

    22 Lectures 
     7 hours 

 Arun Motoori

    118 Lectures 
     17 hours 

 Arun Motoori

    278 Lectures 
     38.5 hours 

 Lets Kode It
 Print
 Add Notes
 Bookmark this page