If we have an SSO application and we want to login to the application with those credentials, we can use a small modification to our driver properties.
Add the following argument to driver options and it will use the existing user credentials.
string loggedInUser = System.Environment.UserName; //read the Logged in user name driverOptions.AddArguments(@"user-data-dir=C:\Users\" + loggedInUser + @"\AppData\Local\Google\Chrome\User Data");
We may get the below error while continues execution of the scripts using selenium.
OpenQA.Selenium.WebDriverException: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir.
This happens due to the open browser from the previous session. So in order to avoid this issue make sure to close the browser before triggering the script.
If possible, close the browser programmatically before each execution.
No comments:
Post a Comment