
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Open Browser in Incognito Mode Using Python Selenium WebDriver
We can open a browser window in incognito/private mode with Selenium webdriver in Python using the ChromeOptions class. We have to create an object of the ChromeOptions class.
Then apply the method add_argument to that object and pass the parameter -- incognito has a parameter. Finally, this information has to be passed to the webdriver object.
Syntax
c = webdriver.ChromeOptions() c.add_argument("--incognito")
Example
from selenium import webdriver #object of ChromeOptions class c = webdriver.ChromeOptions() #incognito parameter passed c.add_argument("--incognito") #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe",options=c) driver.implicitly_wait(0.5) #launch URL driver.get("https://www.tutorialspoint.com/tutor_connect/index.php")
Output
Advertisements