Untitled

mail@pastecode.io avatar
unknown
java
a month ago
3.5 kB
2
Indexable
Never
package compamy.nopcommerce.users;

import java.lang.reflect.Method;
import java.time.Duration;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.relevantcodes.extentreports.LogStatus;

import PageObject_User.UserChangePasswordPageObject;
import PageObject_User.UserHomePageObject;
import PageObject_User.UserLoginPageObject;
import PageObject_User.UserMyAccountSideBarPageObject;
import PageObject_User.UserOrderPageObject;
import PageObject_User.UserRegisterPageObject;
import commons.BasePage;
import commons.BaseTest;
import commons.Page_Generator_Manager;
import reportConfigs.ExtentManager;

public class Level15_Extent_and_AttachScreenShot extends BaseTest {
	private WebDriver driver;
	String projectPath = System.getProperty("user.dir");
	private UserHomePageObject homePage;
	private UserRegisterPageObject registerPage;
	private UserLoginPageObject loginPage;
	
	String emailAddress = "automationtest" + generateFakeNumber() + "@gmail.com";
	String firstName="Automation";
	String lastName="Test";
	String Password="123456";
	String confirmPassword="123456";
	String invalidEmail ="123@123.";
	String notExistEmail = "ghtktest@gmail.com";
	String incorrectPassword = "654321";
	
	
  @BeforeClass
  public void beforeClass() {
	  System.setProperty("webdriver.gecko.driver", projectPath + "\\browsersDriver\\geckodriver.exe");
	  driver = new FirefoxDriver();
	  driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
	  driver.get("https://demo.nopcommerce.com/");
	  
	  homePage = Page_Generator_Manager.UserHomePageObject(driver);
	  registerPage = homePage.clickToRegisterLink();
      
	  registerPage.inputToFirstNameTextbox(firstName);
	  registerPage.inputToLastNameTextbox(lastName);
	  registerPage.inputToEmailTextbox(emailAddress);
	  registerPage.inputToPasswordTextbox(Password);
	  registerPage.inputToConfirmPasswordTextbox(confirmPassword);
	  registerPage.clickToRegisterButton();
	  Assert.assertEquals(registerPage.getSuccessRegisterMessage(), "Your registration completed");
	  
	  
	  }
	
  @Test
  public void Login_01_Empty_Data(Method method) { 
	  ExtentManager.startTest(method.getName(), "Login_01_Empty_Data");
	  loginPage = homePage.clickToLoginLink();
	  
	  ExtentManager.getTest().log(LogStatus.INFO, "Login - TC01 - Step01 - Click to Login button");
	  loginPage.clickToLoginButton();
	  
	  ExtentManager.getTest().log(LogStatus.INFO, "Login - TC01 - Step02 - Assert error message");
	  Assert.assertEquals(loginPage.getEmailErorrText(), "Please enter your email.");
  }
  

  @Test
  public void Login_06_Correct_Email_Correct_Password(Method method) {
	  ExtentManager.startTest(method.getName(), "Login_06_Correct_Email_Correct_Password");
	  loginPage = homePage.clickToLoginLink();
	  
	  ExtentManager.getTest().log(LogStatus.INFO, "Login - TC06 - Step01 - Fill to email address and password");
	  loginPage.inputToEmailTextbox(emailAddress);
	  loginPage.inputToPasswordTextbox(Password);
	  
	  ExtentManager.getTest().log(LogStatus.INFO, "Login - TC06 - Step02 - Click to login button");
	  loginPage.clickToLoginButton();
	  
	  Assert.assertTrue(loginPage.isMyaccountDisplay());
	  
  }
  

  @AfterClass
  public void afterClass() {
	  driver.quit();
  }
  

}
Leave a Comment