danielle
danielle

Reputation: 883

Selenium drivers don't remember user authentication

The application I'm testing requires a login with the user's Google account. Every time I log in, it displays/requires that I select the 'Allow Access' button as if it doesn't remember that I have already added it to my list of Authorized Access for my Google account. This doesn't happen when I test manually, only when I'm running Selenium. Has anyone come across an issue like this or know of a solution? Thanks in advance.

WebDriver driver = selenium_driver.get(); // using chrome driver 
baseUrl = defaults.getProperty("base_url"); // this is set to my localhost 
helper.ConnectToURL(baseUrl);

When this started happening, I had been using Selenium 2.28.0--since then, I've updated to 2.31.0 but it's exhibiting the same behavior.

Upvotes: 2

Views: 1876

Answers (1)

tmacblane
tmacblane

Reputation: 19

Disclaimer: This is currently not possible according to the ChromeDriver wiki. It states in the "Known Issues" section "Cannot specify a custom profile". (https://code.google.com/p/selenium/wiki/ChromeDriver)

At some point when it is fixed, I would suggest creating or using the default chrome profile that has your authorized access set that your test uses whenever it starts up.

According to the ChromeDriver wiki: "By default, ChromeDriver will create a new temporary profile for each session".

Checkout this post for more in depth information regarding capabilities: http://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches

I do my work in .NET and Windows; my set up would look something like this:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("start-maximized");
chromeOptions.AddArgument("user-data-dir=C:\\Users\\username\\AppData\\Local\\Google\\Chrome\\User Data\\Default");
capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability(ChromeOptions.Capability, chromeOptions);
ChromeDriver chromeDriver= new ChromeDriver(this.Environment.ChromeDriverLocation, chromeOptions);

If you are not limited to using Chrome for your tests you are able to create and use custom profiles using Firefox.

Upvotes: 1

Related Questions