0

I am trying to run my e2e tests using protractor and chrome. I use chrome in incognito mode, as I have to test different logins and I do not want SSO to be enabled. It works when I open an incognito window and I manually navigate to the URL, I am getting asked for a username and password. However, when I run the same scenario from protractor (so still using incognito and the same URL), I am getting logged in automatically.

Anybody has any suggestions? Does it have something to do with the chrome profile that is getting loaded? I am new to this, so any suggestion is welcomed. Thank you!

My capabilities section of the config:

config.capabilities = {
        browserName: 'chrome',
        chromeOptions: {
            args: ['disable-infobars',"--incognito","--log-level=3","--disable-gpu", "--window-size=1600,1200"]
        },
        //shardTestFiles: true,
        //maxInstances: 3,
        deviceProperties:{
            browser: {
                name: 'chrome',
                version: 'latest'
            },
            platform: {
                name: 'Windows',
                version: '10'
            }
        }
}
cris
  • 171
  • 3
  • 14
  • You need to clear previous session. See here: https://stackoverflow.com/questions/40296093/protractor-clear-browsing-data-completely – Kacper Feb 19 '19 at 11:44
  • Thanks for suggestion. When trying to clear the localStorage/sessionStorage I am getting the following error: Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs. Any idea? – cris Feb 19 '19 at 13:10
  • @cristina That error is likely caused by [chromium settings](https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document). Could you post your capabilities section of your conf? – DublinDev Feb 24 '19 at 11:19
  • @DublinDev Sorry for the late post, I had to work on a different project for a while. I still have this error though, I have posted the capabilities section. I have looked over the possible chromium settings (there are many), so if you have any suggestion on which one should I use, please let me know. Thank you! – cris Mar 19 '19 at 13:14
  • This is not something I've ever used, and am not sure of it's implementation but this property `profile.default_content_setting_values.cookies` seems like it could be of significance. There are some [related threads](https://stackoverflow.com/questions/18106588/how-to-disable-cookies-using-webdriver-for-chrome-and-firefox-java) in java. note: I am referring to the error you mentioned in your comment above – DublinDev Mar 20 '19 at 11:57

1 Answers1

0

Try the below one

browser.get('#/Login');
        browser.executeScript('window.localStorage.clear();');
        browser.executeScript('window.sessionStorage.clear();');
        browser.driver.manage().deleteAllCookies(); 

Hoep it helps you

Madhan Raj
  • 1,404
  • 1
  • 7
  • 13
  • 1
    I have tried, with all this in a BeforeAll for now, but it still logs me in...I have tried, have all in a BeforeAll for now, just to try it out, but it still logs me in. BeforeAll({timeout: 100 * 1000}, function () { browser.ignoreSynchronization = true; browser.get(config.baseUrl); browser.executeScript('window.localStorage.clear();'); browser.executeScript('window.sessionStorage.clear();'); browser.driver.manage().deleteAllCookies(); }); – cris Feb 19 '19 at 13:25