- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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.
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.
#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.
- How do I open Chrome in selenium WebDriver?
- How to setup Chrome driver with Selenium on MacOS?
- Downloading a file at a specified location through python and selenium using Chrome driver.
- Get text using selenium web driver in python?
- How to invoke the Chrome browser in Selenium with python?
- How do I pass environment variables to Docker containers?
- How to run Selenium tests on Chrome Browser using?
- How to save as PDF on Chrome using Selenium
- How can I download Microsoft WebDriver/Edge Driver to use with Selenium?
- How to get all options of a dropdown using Python Selenium webdriver?
- How to get text with selenium web driver in python?
- How do I download Selenium RC?
- How do I use Selenium IDE?
- How do I pass a variable to a MySQL script?
- How do I switch to the active tab in Selenium?