- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I pass options to the Selenium Chrome driver using Python?
We can pass options to the Selenium Chrome driver using Python. This can be with the help of the ChromeOptions and the DesiredCapabilities class. For the ChromeOptions, we have to create an object for that class.
Then we shall take the help of the add_argument method and pass the option we want to send to the browser as a parameter to the method. Finally, this information must be given to the web driver.
Example
Code Implementation.
from selenium import webdriver from selenium.webdriver.chrome.options import Options as ChromeOptions #object of ChromeOptions op = webdriver.ChromeOptions() #add option op.add_argument('--enable-extensions') #pass option to webdriver object driver = webdriver.Chrome(chrome_options=op)
We can also add capabilities with the help of DesiredCapabilities class.
Code Implementation.
#object of DesiredCapabilities c = webdriver.DesiredCapabilities.Chrome.copy() #set capability to True c['acceptInsecureCerts'] = True #pass capability to webdriver object driver = webdriver.Chrome(desired_capabilities=c)
In this way, we can pass the Chrome options.
Advertisements