TestNG

  • 13
    Mar

    How to run TestNG scenarios from main class

    Following code snippet demonstrates how to execute a TestNG class from main function TestNG Class (this can be run independently as TestNG Suite) ————————————————————- import org.testng.annotations.Test; public class abc...

    Read More
  • 29
    Nov

    Configure log level with TestNG

    While working with testsuites it is sometimes necessary to diagnose / debug to pin point odd behavior during execution.  This can be accomplished by increasing the log-level for TestNG....

    Read More
  • 03
    Sep

    find broken links on a webpage

    Following code snippet can be used to details of link and their working / not working (broken) details on a page package practice; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL;...

    Read More
  • 03
    Sep

    solution to “unable to find valid certification path to requested target” in java

    How to import certificate offline Go to URL in your firefox browser, click on HTTPS certificate chain (next to URL address). Click “more info” > “security” > “show certificate”...

    Read More
  • 03
    Sep

    Running a TestNG case multiple time in a batch of two

    In order to execute a script via two threads and three times total, we can use following code snippet import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; import org.testng.annotations.Test; public class...

    Read More
  • 03
    Sep

    dependsOnMethods() example in TestNG

    following code snippet shows example of dependsOnMethods function import org.testng.annotations.Test; public class TestNGExample { @Test(groups = { “Automation” }) public void driver() { System.out.println(“Initialize Browser”); } @Test(dependsOnMethods = {...

    Read More
  • 29
    Aug

    handling WebDriver exceptions before test execution with TestNG

    One can use static initialization block to catch exception like this: public class A { static final WebDriver wd; static { try { wd = new FirefoxDriver(); } catch...

    Read More
  • 29
    Aug

    Softasserts in TestNG

    There are two types of Assert: 1. Hard Assert => script execution stops (on failure of such asserts) 2. Soft Assert => script execution continues (on failure of such...

    Read More
  • 17
    Jul

    Creating a datadriven tests with TestNG

    Following function can be used to create a data driven tests using “Dataprovider” annotation of TestNG import java.util.HashMap; 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.DataProvider; import...

    Read More
  • 27
    Jun

    Executing tests in parallel with TestNG Framework

    Step 1: Create a testing.xml with parallel keyword as Step 2: create PE1 and PE2 classes (which needs to be executed in parallel) package TestNG; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver;...

    Read More