Skip to content

Instantly share code, notes, and snippets.

import org.junit.After;
import org.junit.Before;
/**
* Base class for all tests
*/
public class TestBase {
@Before
public void setUp() throws Exception {
import io.github.bonigarcia.wdm.ChromeDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.DefaultElementLocatorFactory;
import org.openqa.selenium.support.ui.WebDriverWait;
/**
* Base class for all pages and page fragments
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
public class FacebookPostFragment extends PageBase{
@FindBy(className = "profileLink")
private WebElement poster;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
public class FacebookSportPostsPage extends PageBase{
@FindBy(id = "facebook")
private WebElement facebookContent;
import org.junit.Test;
public class PageFragmentsExampleTest extends TestBase {
@Test
public void shareSecondPost() {
FacebookSportPostsPage facebookPage = FacebookSportPostsPage.open();
FacebookPostFragment secondPost = facebookPage.getPostByIndex(2);
secondPost.share();
}