Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.