Skip to content

Instantly share code, notes, and snippets.

@ham1
Last active October 16, 2016 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ham1/0bf7d1cc59e5e406b53e to your computer and use it in GitHub Desktop.
Save ham1/0bf7d1cc59e5e406b53e to your computer and use it in GitHub Desktop.
Handling links which could return different page objects
package ai.pages;
import com.frameworkium.core.ui.annotations.Visible;
import com.frameworkium.core.ui.pages.BasePage;
import com.frameworkium.core.ui.pages.PageFactory;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class Test extends BasePage<Test> {
@Visible
@FindBy(css = "#my_id")
private WebElement saveLink;
/**
* Saves the record and creates a new page object for the page expected
* to display after the save.
* Example usage: <code>sideNavigation.savePage(SomePage.class);</code>
*/
public <T extends BasePage<T>> T savePage(Class<T> expectedPageObjectClass) {
// this returns different pages depending upon which page you started on
saveLink.click();
return PageFactory.newInstance(expectedPageObjectClass);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment