0
package com.crm.qa.test;

import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import com.crm.qa.base.TestBase;
import com.crm.qa.pages.ContactsPage;
import com.crm.qa.pages.HomePage;
import com.crm.qa.pages.LoginPage;
import com.crm.qa.util.TestUtil;

public class ContactPageTest extends TestBase {

  LoginPage loginPage;
  HomePage homePage;
  TestUtil testUtil;
  ContactsPage contactsPage;

  public ContactPageTest() {
    super();
  }
  @BeforeMethod
  public void setup() {
    initializaton();
    TestUtil    testUtil = new TestUtil();
    contactsPage =new ContactsPage();
    loginPage = new LoginPage();
    homePage =loginPage.Login(prop.getProperty("username"), prop.getProperty("password"));
    testUtil.switchToFrame();
    homePage.clickOnContactsLink();
 }

 @Test(priority=1)
 public void verifyContactsPageLabel() {
    Assert.assertTrue(contactsPage.verifyContactsLabel(), "contacts label is missing on the page");
 }

 @Test(priority =2)
 public void selectMultipleContactTest() {
    contactsPage.selectContactsByName("test2 test2");
    contactsPage.selectContactsByName("ui uiii");
 }
 @Test(priority =4)
 public void validateCreateNewContact() {
    homePage.clickOnNewContactLink();
    contactsPage.createNewContact("Mr", "Tom", "peter", "Google");
 }

 @AfterMethod
 public void tearDown() {
    driver.quit();
 }
}


=======================================================================
(Base class)
package com.crm.qa.base;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import com.crm.qa.util.TestUtil;

public class TestBase {
   public static WebDriver driver;
   public static Properties prop;
   public TestBase() {

      try{  
         prop =new Properties();
         FileInputStream ip = new FileInputStream(System.getProperty("C:\\Users\\LITTIN JOMON\\workspace\\PracticeProject\\src\\main\\java\\com\\crm\\qa\\config\\config.properties"));
         prop.load(ip);
      }
      catch (FileNotFoundException e) {
         e.printStackTrace();
      } catch(IOException e) {
         e.printStackTrace();
}}

public static void initializaton() {
   String browserName = prop.getProperty("browser");
      if(browserName.equals("chrome")) {

      System.setProperty("webdriver.chrome.driver", "C:\\Users\\LITTIN JOMON\\Downloads\\exe\\chromedriver.exe");

      driver = new ChromeDriver ();
}
   driver.manage().window().maximize();
   driver.manage().deleteAllCookies();
   driver.manage().timeouts().pageLoadTimeout(TestUtil.PAGE_LOAD_TIMEOUT, 
   TimeUnit.SECONDS);
   driver.manage().timeouts().implicitlyWait(TestUtil.IMPLICIT_WAIT, TimeUnit.SECONDS);
   driver.get(prop.getProperty("url"));
}
}
  • Welcome to SO. One line Description and pasting the source code is not helpful. Also mention what you are trying to do. Add the error log and more description to your question. Also go through the help section on how to as a good question – Alok May 31 at 1:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.