My company uses Multi-factor authentication to restrict access to some sites. Is it possible to copy user profile from firefox and use it in my new window?
-
What are you trying to achieve? By "some sites" you mean external sites or your product you want to check? If the former, what is the relevance for using Selenium? If the later, why not simply feature flag out the auth in test environments?– João FariasCommented Jan 7, 2020 at 17:59
1 Answer
Yes you can achieve this using profile:
Just login to the system and save the login session,
you can get profile folder by typing chrome://version in tab:
Open path\Google\chrome folder
goto user data folder
- Copy the path to Default folder
Now set it in chromeoptions:
chromeOptions:{'args': ['--user-data-dir=%yourpath%\\Local\\Google\\Chrome\\User Data']}
Note : this code is for protractor , you can use the python equivalent
make sure that there is no space after '=' sign and now quotes eg don't use '--user-data-dir="%yourpath%\\Local\\Google\\Chrome\\User Data"'
Also make sure all chrome sections are closed
If you are copying th profile to another folder say testprofile, keep the folder name as default so you just need to use
chromeOptions:{'args': ['--user-data-dir=%yourpath%\\testprofile']}
if the profile folder is not as testprofile\Default the you have to pass it as
--profile-directory=<thenewfoldername>