Last active
October 16, 2016 09:50
-
-
Save ham1/0bf7d1cc59e5e406b53e to your computer and use it in GitHub Desktop.
Handling links which could return different page objects
This file contains 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
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