samedi 26 décembre 2020

How to use dataProvider against multiple testng method using selenium testng code

could you please suggest what could be the issue with my code , After using dataprovider my test method Test2 and Test3 both are looks like unreachable,can you provide me the solution that how i could fix this issue without putting all the code into single Test method

  1. while using data provider i'm only able to reach Test1 code means after executing my code i am getting below output (see below output)

OUTPUT

Before Test case

Print Test1

where my expected output should be (see below out put)

OUTPUT

Before Test case

Print Test1

Print Test2

Print Test2

public class Test extends DriverConfig {
    
    @DataProvider
    public Iterator<String> getTestData() throws Exception {
        driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
        ArrayList<String> getclientProduct = sftpCon.clientProduct("Client Type");
        System.out.println("getclientProduct----------" + getclientProduct);
        System.out.println("Before Test case");
        return getclientProduct.iterator();
    
    }
    
    @Test(priority = 1, retryAnalyzer = com.brcc.tool.RetryFailedTestCases.RetryTestCases.class,dataProvider = "getTestData")
    public void A1(String clientName,String clientAddress) throws Exception {

        wait = new WebDriverWait(driver, 10);
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        System.out.println("Print Test1");
    }
    @Test(priority = 2, retryAnalyzer = com.brcc.tool.RetryFailedTestCases.RetryTestCases.class)
    public void A2() throws Exception {
        wait = new WebDriverWait(driver, 80);
        System.out.println("Print Test2");
        
    }

    @Test(priority = 3, retryAnalyzer = com.brcc.tool.RetryFailedTestCases.RetryTestCases.class)
    public void A3() throws Exception {
        wait = new WebDriverWait(driver, 10);
        System.out.println("Print Test3");
        
    }

}

Aucun commentaire:

Enregistrer un commentaire