Created
August 17, 2013 08:29
-
-
Save prule/6255912 to your computer and use it in GitHub Desktop.
My version of an Abstract Page Object for using with Selenium and JBehave - utility behaviour for clicking links by text, selecting a JSF/PrimeFaces selectOne option, and waiting for ajax to complete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import net.thucydides.core.pages.PageObject; | |
| import org.apache.commons.lang3.StringUtils; | |
| import org.openqa.selenium.By; | |
| import org.openqa.selenium.WebDriver; | |
| public abstract class AbstractPage extends PageObject { | |
| public AbstractPage(WebDriver driver) { | |
| super(driver); | |
| } | |
| public void waitForAjax() { | |
| waitForRenderedElements(By.className("ajaxLoadingImg")); | |
| waitForRenderedElementsToDisappear(By.className("ajaxLoadingImg")); | |
| } | |
| public void clickLinkWithText(String linkText) { | |
| getDriver().findElement(By.linkText(linkText)).click(); | |
| } | |
| public void selectOne(String idPrefix, String value) { | |
| if (StringUtils.isNotBlank(value)) { | |
| getDriver().findElement(By.id(idPrefix + "_label")).click(); | |
| getDriver().findElement(By.xpath("//div[@id='" + idPrefix + "_panel']/div/ul/li[text()='" + value + "']")).click(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment