Selenium Test Automation: How to build testNG base using testNg annotations?

Selenium

BriefTitle: 
testNg base

Step 1: Create base test class

  1. Right click on src/main/java folder, select New > Class
  2. Enter class name as BaseTest
  3. Click Finish

Step 2: Write methods using testNG annotation

Add the below code in BaseTest class:

package com.examplesite.base;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;

public class BaseTest {
protected WebDriver driver;

    @Parameters ({"browser"})
@BeforeMethod
protected void MethodSetup(String browser){
System.out.println("Launch browser. ");
driver = Browsers.getDriver(browser);
}

@AfterMethod
protected void TearDown(){
System.out.println("Tear down. ");
}
}

Sorting: 
13

Add new comment

Selenium