Module 4.1 - Selenium Page Object Design Pattern - Test Class Example

From Training Material
Jump to navigation Jump to search
package com.shk.webdriver.sanity;

import static org.junit.Assert.*;

import org.junit.Test;

public class LoginScenarioTest extends WebDriverBase{

 
	        
	             
	        @Test  
	        public void testLogin() throws Exception {  
	      
	            LoginPage loginPage = new LoginPage(driver,0);  
	            HomePage homePage = loginPage.loginAs("someone@hotmail.com", "welcome1");  
	            assertEquals("some one",homePage.getHomePageWelcomeMessage());  
	      
	        }  
	      
	        @Test  
	        public void testFailedLogin() throws Exception {  
	      
	            LoginPage loginPage = new LoginPage(driver,0);  
	            loginPage.failLoginAs("nobody", "WRONG");  
	            assertTrue(loginPage.getErrorMessage().contains("Please enter your email address in the format someone@example.com."));  
	        }  
	      
	}