You can create classes like this,
Your POM class something look like this:-
public class Homepage{
WebDriver driver;
public Homepage(WebDriver driver) {
//super();
this.driver = driver;
}
private static final By loginLink= By.linkText("LOGIN");
private static final By infostoreLink= By.linkText("Infostore");
public void clickInfostoreLink() {
WebElement element= driver.findElement(loginLink);
Actions action= new Actions(driver);
action.moveToElement(element);
action.build().perform();
driver.findElement(infostoreLink).click();
}
}
Your Test class like this:-
public class LoginTest extends BaseTest {
@Test()
public void infostoreTest() {
Homepage add= new Homepage(driver);
add.clickInfostoreLink();
//Whatever you want to test according to your test case
}
}
and BaseTest class look like this:-
public class BaseTest {
public static WebDriver driver;
@BeforeTest
public void LaunchApplication()
{
System.setProperty("webdriver.chrome.driver", "C:\\Intel\\chromedriver.exe");
driver= new ChromeDriver();
driver.get(baseURL);
driver.manage().window().maximize();
}
@AfterTest
public void closeApplication()
{
driver.quit();
}
}
hope this will help you to get some idea about POM.