Skip Selenium TestCase Run using TestNG – User friendly Tech help

Scenario:-We have a test case in the test set, which is not ready for testing and we wont this test case to be disabled while Selenium is executing the complete test suite.
n
nSolution:-
nWe can disabled the test case in TestNG using enabled property.
n
nSyntax
n@Test(enabled=false)
nBy default it is enabled= true
n
nCode:-
n
nXML file:-
n
n









n

nJava:-
n

n

package TestNG_Learning;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class DisableTest {
private WebDriver driver;
@Test
public void login() {
//Fill the UserName and Password fields
driver.findElement(By.id("userName")).sendKeys("uftHelp");
driver.findElement(By.id("password")).sendKeys("Password"); }
//Test is disabled
@Test(enabled=false)
public void signIn() {
//Click the Sign in Button
driver.findElement(By.id("SignIn")).click();
//Clicking on the alert message
driver.switchTo().alert().accept(); }
@BeforeMethod
public void beforeMethod() {
driver = new FirefoxDriver();
//Adding Implicit wait
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//Maximize browser
driver.manage().window().maximize();
//Open the Login Application
driver.get("http://www.ufthelp.com/p/testpage.html"); }
@AfterMethod
public void afterMethod() {
//Closing the browser
driver.quit(); }}

n

n
nOutput:-

n

n

n

n

n

n

n

n

Output result have missing “signIn” test case 

n

More practical scenarios

Was this article helpful?
YesNo

Similar Posts