- 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 to use a specific chrome profile in selenium?
We can use a specific Chrome profile in Selenium. This can be done with the help of the ChromeOptions class. We need to create an object of this class and then apply addArguments method on it.
The path of the specific Chrome profile that we want to use is passed as a parameter to this method. We can open Chrome’s default profile with Selenium. To get the Chrome profile path, we need to input chrome://version/ in the Chrome browser and then press enter.
Syntax
o = webdriver.ChromeOptions() o.add_argument = {'user-data-dir':'/Users/Application/Chrome/Default'}
Example
Code Implementation
from selenium import webdriver #object of ChromeOptions class o = webdriver.ChromeOptions() #adding specific Chrome Profile Path o.add_arguments = {'user-data-dir':'<path of specific Chrome profile>'} #set chromedriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe", options=o) #maximize browser driver.maximize_window() #launch URL driver.get("https://www.tutorialspoint.com/index.htm") #get browser title print(driver.title) #close browser driver.close()
Output
Advertisements