Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add stability to the Google OpenID test
Browse files Browse the repository at this point in the history
The Google OpenID test relies on permissions to be set for the
localhost application - remove these if they exist already.
There is also a slight delay on the enabling of the "Accept" button.
  • Loading branch information
djansen-redhat committed Sep 30, 2013
1 parent 47464ce commit f53ddb8
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 82 deletions.
Expand Up @@ -67,11 +67,16 @@ public String getTitle()
return driver.getTitle();
}

public String getUrl()
{
return driver.getCurrentUrl();
}

public FluentWait<WebDriver> waitForTenSec()
{
return ajaxWaitForTenSec;
}

protected void clickAndCheckErrors(WebElement button)
{
button.click();
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -26,6 +26,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.zanata.page.BasePage;
import org.zanata.page.googleaccount.GoogleAccountPage;
import org.zanata.page.utility.DashboardPage;

@Slf4j
Expand Down
Expand Up @@ -18,7 +18,7 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.page.account;
package org.zanata.page.googleaccount;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -56,16 +56,15 @@ public GoogleAccountPage enterGooglePassword(String password)
return new GoogleAccountPage(getDriver());
}

public EditProfilePage clickSignIn()
public GooglePermissionsPage clickSignIn()
{
signInButton.click();
return new GooglePermissionsPage(getDriver());
}

// May return a Permissions request page, if this is the first run
if(!getDriver().getTitle().contains("Edit Profile"))
{
GooglePermissionsPage googlePermissionsPage = new GooglePermissionsPage(getDriver());
googlePermissionsPage.acceptPermissions();
}
return new EditProfilePage(getDriver());
public GoogleManagePermissionsPage clickPermissionsSignIn()
{
signInButton.click();
return new GoogleManagePermissionsPage(getDriver());
}
}
@@ -0,0 +1,62 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.page.googleaccount;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.zanata.page.AbstractPage;

/**
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
public class GoogleManagePermissionsPage extends AbstractPage
{

public GoogleManagePermissionsPage(WebDriver driver)
{
super(driver);
}

public GoogleManagePermissionsPage removePermission(String permissionName)
{
if (pageContainsPermission(permissionName))
{
getDriver().findElement(By.name(permissionName))
.findElement(By.cssSelector("input[type='submit']"))
.click();
}
return new GoogleManagePermissionsPage(getDriver());
}

public boolean pageContainsPermission(String permissionName)
{
try
{
return getDriver().findElement(By.name(permissionName)).isDisplayed();
}
catch(NoSuchElementException nsee)
{
// Permission not listed
return false;
}
}
}
@@ -0,0 +1,50 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.page.googleaccount;

import com.google.common.base.Function;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.zanata.page.AbstractPage;
import org.zanata.page.account.EditProfilePage;

/**
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
public class GooglePermissionsPage extends AbstractPage
{
public GooglePermissionsPage(WebDriver driver)
{
super(driver);
}

public EditProfilePage acceptPermissions()
{
waitForTenSec().until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return getDriver().findElement(By.id("submit_approve_access")).isEnabled();
}
});
getDriver().findElement(By.id("submit_approve_access")).click();
return new EditProfilePage(getDriver());
}
}
Expand Up @@ -14,6 +14,12 @@ public <P extends AbstractPage> P goToPage(String url, Class<P> pageClass)
return PageFactory.initElements(driver, pageClass);
}

public <P extends AbstractPage> P goToUrl(String url, Class<P> pageClass)
{
driver.navigate().to(url);
return PageFactory.initElements(driver, pageClass);
}

private String toUrl(String relativeUrl)
{
return hostUrl + removeLeadingSlash(relativeUrl);
Expand Down
@@ -0,0 +1,51 @@
/*
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.workflow;

import org.zanata.page.googleaccount.GoogleAccountPage;
import org.zanata.page.googleaccount.GoogleManagePermissionsPage;

/**
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
public class GoogleWorkFlow extends AbstractWebWorkFlow
{
private static String permissionsPageLink = "https://accounts.google.com/b/0/IssuedAuthSubTokens?hl=en_GB";
private static String forceLogoutLink = "https://accounts.google.com/Logout?service=lso";

public GoogleManagePermissionsPage resetGooglePermissions(String googleUsername, String password)
{
GoogleAccountPage googleAccountPage = new BasicWorkFlow()
.goToUrl(permissionsPageLink, GoogleAccountPage.class);

return googleAccountPage
.enterGoogleEmail(googleUsername)
.enterGooglePassword(password)
.clickPermissionsSignIn()
.removePermission("localhost");
}

public GoogleAccountPage forceLogout()
{
return new BasicWorkFlow().goToUrl(forceLogoutLink, GoogleAccountPage.class);
}

}
Expand Up @@ -21,7 +21,7 @@
package org.zanata.workflow;

import org.zanata.page.account.EditProfilePage;
import org.zanata.page.account.GoogleAccountPage;
import org.zanata.page.googleaccount.GoogleAccountPage;
import org.zanata.page.utility.HomePage;

/**
Expand All @@ -36,10 +36,13 @@ public HomePage registerGoogleOpenID(String name, String username, String passwo
.goToHome()
.clickSignInLink()
.selectGoogleOpenID();

EditProfilePage editProfilePage = googleAccountPage
.enterGoogleEmail(email)
.enterGooglePassword(password)
.clickSignIn();
.clickSignIn()
.acceptPermissions();

return editProfilePage
.enterName(name)
.enterUserName(username)
Expand Down
Expand Up @@ -22,6 +22,7 @@

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.zanata.feature.googleopenid.GoogleOpenIDTest;

/**
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
Expand All @@ -33,7 +34,7 @@
UsernameValidationTest.class,
ValidEmailAddressTest.class,
InvalidEmailAddressTest.class,
OpenIDTest.class
GoogleOpenIDTest.class
})
public class AccountTestSuite
{
Expand Down

0 comments on commit f53ddb8

Please sign in to comment.