Created
June 5, 2017 05:56
-
-
Save swapnilshrikhande/882f741d0557ad56cf70847289592dcc to your computer and use it in GitHub Desktop.
Example page model class using base PageObjectModel class
This file contains hidden or 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 com.eternussolutions; | |
import java.io.OutputStreamWriter; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
// Simple page object model class | |
public class AdditionPageObjectModel extends PageObjectModel { | |
//constants | |
public static final String moduleURL="add.html"; | |
//Collect all selectors at one location for ease of maintainance | |
By inputASelector = By.id("ainput"); | |
By inputBSelector = By.id("binput"); | |
By outputSelector = By.id("coutput"); | |
By calcButtonSelector = By.id("calculate"); | |
public AdditionPageObjectModel(WebDriver webDriverP,String baseURLP){ | |
super(webDriverP,baseURLP); | |
} | |
//public methods | |
public void load(){ | |
//1. load | |
driver.get(baseURL+moduleURL); | |
} | |
public void setInputAValue(String input){ | |
clearInput(inputASelector); | |
setValue(inputASelector,input); | |
} | |
public void setInputBValue(String input){ | |
clearInput(inputBSelector); | |
setValue(inputBSelector,input); | |
} | |
public String getOutputValue(){ | |
return getInputFieldValue(outputSelector); | |
} | |
public void triggerCalculation(){ | |
triggerEvent(calcButtonSelector,CLICK_EVENT); | |
} | |
} |
This file contains hidden or 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 com.eternussolutions; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
public class LoginPageObjectModel extends PageObjectModel { | |
public LoginPageObjectModel(WebDriver webDriverP,String baseURLP){ | |
super(webDriverP,baseURLP); | |
} | |
By userNameSelector = By.id("usernameId"); | |
By passwordSelector = By.id("passwordId"); | |
By loginBtnSelector = By.id("loginBtnId"); | |
public void login(String userName,String password){ | |
setValue(userNameSelector, userName); | |
setValue(passwordSelector,password); | |
triggerEvent(loginBtnSelector, CLICK_EVENT); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment