1

Configurations:

OS : Ubuntu
Java version : 8
Selenium : 3.8.0
ChromeDriver : 2.33
Chrome version : 60

I'm automating an application where i have to login in a system using Social media

After entering mobile number it ask for password and there social media icon. If i click lets say google plus, it opens google plus login window then I have to provide credential then the window get closed automatically and user gets login. As shown here

enter image description here

My issue is, after logout from my application if i again try to login using google plus then it perform automatic login (second time it won't ask for google plus credentials as google plus session cookies are there)

So in my script I'm trying to delete all cookies after first test but it is not working code line I've tried :

driver.manage().deleteAllCookies();

For reference complete test look like :

@Test
public void newUserRegistration_GooglePlus_ForAlreadyExistEmail() throws IOException, InterruptedException, JSONException
{
    LogoutAnalyzer.checkLogout();
    loginpage.sendUsername(excel.getCellData(6, 18, 1));
    CommonMethods.waitUntilLoaderGetInvisible(driver);
    TakeScreenshot.passedScreenShot("Username");
    LogWriter.logger.info("Mobile number has entered");
    loginpage.clickSubmitButton();
    CommonMethods.waitUntilLoaderGetInvisible(driver);
    LogWriter.logger.info("Submit button clicked");

    if(loginpage.otpTextbox.size()>0)
    {
        String OTP = otpreader.getOTP(excel.getCellData(6, 18, 1));
        LogWriter.logger.info("Got the OTP via API call OTP is "+OTP);
        loginpage.enterOTP(OTP);
        TakeScreenshot.passedScreenShot("OTP_Entered");
        LogWriter.logger.info("OTP Entered");
        loginpage.clickConfirmCodeButton();
        CommonMethods.waitUntilLoaderGetInvisible(driver);  
        LogWriter.logger.info("Submit button clicked");
        TakeScreenshot.passedScreenShot("Profile_Info");
        loginpage.clickGooglePlusIcon();
        Thread.sleep(5000);
        LogWriter.logger.info("Switch to Google Plus window");
        CommonMethods.switchWindow(driver);
        CommonMethods.waitForElementVisibility(driver, new RCONGooglePlusPage(driver).usernameField);
        TakeScreenshot.passedScreenShot("Google Window");
        sm_helper.googlePlusLogin(excel.getCellData(6, 18, 2), excel.getCellData(6, 18, 3));

        CommonMethods.switchToParentWindow(driver);
        LogWriter.logger.info("Switched back to RContacts window");
        CommonMethods.waitUntilLoaderGetInvisible(driver);
        Assert.assertEquals(loginpage.getValidationMessage(), PropertyFileReader.getProperty("emailAlreadyExistMessage"));
        LogWriter.logger.info(PropertyFileReader.getProperty("emailAlreadyExistMessage"));
    }
    else
    {
        TakeScreenshot.passedScreenShot("Already_registered_User");
        LogWriter.logger.info("This user is already a registered user");
    }

    driver.manage().deleteAllCookies();
    LogWriter.logger.info("all cookies deleted");
}
snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
NarendraR
  • 7,577
  • 10
  • 44
  • 82
  • https://stackoverflow.com/questions/12909332/how-to-logout-of-an-application-where-i-used-oauth2-to-login-with-google. Log out from application does not mean you are logged out from google authentication. Also some answers mention how to force google to log out also. Maybe they work... – Grasshopper Dec 15 '17 at 06:45
  • Possibly reopening the browser window after clearing the cookies will work? – Eugene S Dec 15 '17 at 06:49
  • @Grasshopper, Thanks for suggestion, I got some valuable answer from that link *lgabster* answer. I'm getting logout from gmail but still in next time it ask for choose user to login but what i want is it should open a fresh session as first time it opens – NarendraR Dec 15 '17 at 07:24
  • @NarendraR What happens if you also delete cookies from the google domain after navigating to the logout page as suggested by lgabster – Grasshopper Dec 15 '17 at 07:44
  • @Grasshopper, the previous email user comes in selection to login with – NarendraR Dec 15 '17 at 07:49
  • @NarendraR Try adding the "google-app-engine" tag to the question. May get a better response. – Grasshopper Dec 15 '17 at 09:00
  • @NarendraR Have you resolved this one? I got exactly the same error like you. The driver.delete_all_cookies could not delete google auth cookie, then next time when clicking the button it logged me in automatically – Linh Nhat Nguyen May 07 '20 at 05:47

0 Answers0