Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private LoginPage loginPage;
- private DashboardPage homePage;
- @Before
- public void setUp() throws Exception {
- loginPage =new LoginPage(driver);
- homePage = new DashboardPage (driver);
- }
- @After
- public void tearDown() throws Exception {
- }
- @Test
- public void test() {
- loginPage.load();
- loginPage.login();
- homePage.getWelcomeMessage();
- String actualWelcome=homePage.getWelcomeMessage();
- assertEquals("Welcome Admin",actualWelcome);
- homePage.logout();
- }
- public LoginPage(WebDriver driver) {
- super(driver);
- }
- public void login() {
- // TODO Auto-generated method stub
- driver.findElement(By.id("txtUsername")).sendKeys("admin");;
- driver.findElement(By.id("txtPassword")).sendKeys("Password");;
- driver.findElement(By.id("btnLogin")).click();;
- }
- public DashboardPage(WebDriver driver) {
- super(driver);
- // TODO Auto-generated constructor stub
- }
- public String getWelcomeMessage() {
- return wait.until(ExpectedConditions.presenceOfElementLocated(
- By.id("welcome"))).getText();
- }
- public void logout() {
- wait.until(ExpectedConditions.visibilityOfElementLocated(
- By.linkText("Logout"))).click();
- }
- protected WebDriver driver;
- protected WebDriverWait wait;
- @Before
- public void setUp() throws Exception {
- System.setProperty("webdriver.gecko.driver", "geckodriver.exe");
- driver = new FirefoxDriver();
- wait=new WebDriverWait(driver, 5);
- driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
- }
- @After
- public void basetearDown() throws Exception {
- driver.quit();
Add Comment
Please, Sign In to add comment