Quantcast

DataProvider is able to execute only single @Test only

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

DataProvider is able to execute only single @Test only

Mahender Tirumala
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

⇜Krishnan Mahadevan⇝
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

Mahender Tirumala
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("<a href="http://www.google.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com&#39;;return true;" onclick="this.href=&#39;http://www.google.com&#39;;return true;">http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="paFsgVY1AgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">2mah...@...> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="paFsgVY1AgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="paFsgVY1AgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

Mahender Tirumala
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser



On Wednesday, June 8, 2016 at 4:24:37 PM UTC+5:30, Mahender Tirumala wrote:
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("<a href="http://www.google.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com&#39;;return true;" onclick="this.href=&#39;http://www.google.com&#39;;return true;">http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

⇜Krishnan Mahadevan⇝
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser

​That cannot be possible because I sent you the code after personally executing it. Make sure that all your annotations are from TestNG and you aren't using the @BeforeClass and @AfterClass from JUnit. That can be the only reason why you don't see the browser cleaning up properly.


Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.
I dont quite understand what you are saying here. The data provider here provides parameters for the constructor so that TestNG may use those parameters to invoke the constructor and produce test class instances. So if you want another test class with a different type of a constructor then obviously yes you would need to write up a new data provider. 


also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider

No I don't have any ready made logic available at my hand. But if you would like to, then you could perhaps take a look at the data providers library that SeLion provides and see if you can leverage that.

To start with you would need to add a dependency on the Selion data provider

<dependency>
    <groupId>com.paypal.selion</groupId>
    <artifactId>SeLion-DataProviders</artifactId>
    <version>1.0.0</version>
</dependency>

You can then look at one of the unit tests to understand how to work with the different variants of data providers that SeLion provides by looking at the unit tests here (or) looking at the samples from the SeLion archetype SimpleDataDrivenTest  and SimpleDataDrivenWithSelectiveRowsTest.

For any further queries on SeLion data providers I would encourage you to post them here : https://groups.google.com/forum/#!forum/selion


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Jun 8, 2016 at 4:39 PM, Mahender Tirumala <[hidden email]> wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser




On Wednesday, June 8, 2016 at 4:24:37 PM UTC+5:30, Mahender Tirumala wrote:
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

Jessie
Krishnan,

I use TestNG and restAssured for REST web services testing. I use dataProvider reading test data from xls files. In order to run a single test (one row from the test data file), can I use Selion?
Thanks,
Yanan 


On Wednesday, June 8, 2016 at 10:49:25 AM UTC-4, Krishnan wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser

​That cannot be possible because I sent you the code after personally executing it. Make sure that all your annotations are from TestNG and you aren't using the @BeforeClass and @AfterClass from JUnit. That can be the only reason why you don't see the browser cleaning up properly.


Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.
I dont quite understand what you are saying here. The data provider here provides parameters for the constructor so that TestNG may use those parameters to invoke the constructor and produce test class instances. So if you want another test class with a different type of a constructor then obviously yes you would need to write up a new data provider. 


also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider

No I don't have any ready made logic available at my hand. But if you would like to, then you could perhaps take a look at the data providers library that <a href="http://selion.io" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fselion.io\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvnXruvo1sPwT7hjMu3m5jeFLG4A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fselion.io\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvnXruvo1sPwT7hjMu3m5jeFLG4A&#39;;return true;">SeLion provides and see if you can leverage that.

To start with you would need to add a dependency on the Selion data provider

<dependency>
    <groupId>com.paypal.selion</groupId>
    <artifactId>SeLion-DataProviders</artifactId>
    <version>1.0.0</version>
</dependency>

You can then look at one of the unit tests to understand how to work with the different variants of data providers that SeLion provides by looking at the unit tests <a href="https://github.com/paypal/SeLion/tree/develop/dataproviders/src/test/java/com/paypal/selion/platform/dataprovider" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Ftree%2Fdevelop%2Fdataproviders%2Fsrc%2Ftest%2Fjava%2Fcom%2Fpaypal%2Fselion%2Fplatform%2Fdataprovider\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvhrTRiX9op8RNrkkSt6a5cx4vWg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Ftree%2Fdevelop%2Fdataproviders%2Fsrc%2Ftest%2Fjava%2Fcom%2Fpaypal%2Fselion%2Fplatform%2Fdataprovider\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvhrTRiX9op8RNrkkSt6a5cx4vWg&#39;;return true;">here (or) looking at the samples from the SeLion archetype <a href="https://github.com/paypal/SeLion/blob/develop/archetype/src/main/resources/archetype-resources/src/test/java/sample/selion/SimpleDataDrivenTest.java" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Fblob%2Fdevelop%2Farchetype%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Ftest%2Fjava%2Fsample%2Fselion%2FSimpleDataDrivenTest.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG8JeibcXNqAAwpD3yIrcXwdZosog&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Fblob%2Fdevelop%2Farchetype%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Ftest%2Fjava%2Fsample%2Fselion%2FSimpleDataDrivenTest.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG8JeibcXNqAAwpD3yIrcXwdZosog&#39;;return true;">SimpleDataDrivenTest  and <a href="https://github.com/paypal/SeLion/blob/develop/archetype/src/main/resources/archetype-resources/src/test/java/sample/selion/SimpleDataDrivenWithSelectiveRowsTest.java" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Fblob%2Fdevelop%2Farchetype%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Ftest%2Fjava%2Fsample%2Fselion%2FSimpleDataDrivenWithSelectiveRowsTest.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE610kUF591Y__uvcaZC_F2Bpj-TA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Fblob%2Fdevelop%2Farchetype%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Ftest%2Fjava%2Fsample%2Fselion%2FSimpleDataDrivenWithSelectiveRowsTest.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE610kUF591Y__uvcaZC_F2Bpj-TA&#39;;return true;">SimpleDataDrivenWithSelectiveRowsTest.

For any further queries on SeLion data providers I would encourage you to post them here : <a href="https://groups.google.com/forum/#!forum/selion" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/forum/#!forum/selion&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/forum/#!forum/selion&#39;;return true;">https://groups.google.com/forum/#!forum/selion


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Wed, Jun 8, 2016 at 4:39 PM, Mahender Tirumala <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tzWeTDthAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">2mah...@...> wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser




On Wednesday, June 8, 2016 at 4:24:37 PM UTC+5:30, Mahender Tirumala wrote:
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("<a href="http://www.google.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com&#39;;return true;" onclick="this.href=&#39;http://www.google.com&#39;;return true;">http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tzWeTDthAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tzWeTDthAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

Jessie
In reply to this post by ⇜Krishnan Mahadevan⇝
Hi Krishnan,

I use TestNG and restAssured for REST web services testing. I use dataProvider reading test data from xls files. Do you recommend using Selion to run a single test (one row from the test data file)? If not, what do you think is the best way to do it?

Thanks,
Yanan 

On Wednesday, June 8, 2016 at 10:49:25 AM UTC-4, Krishnan wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser

​That cannot be possible because I sent you the code after personally executing it. Make sure that all your annotations are from TestNG and you aren't using the @BeforeClass and @AfterClass from JUnit. That can be the only reason why you don't see the browser cleaning up properly.


Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.
I dont quite understand what you are saying here. The data provider here provides parameters for the constructor so that TestNG may use those parameters to invoke the constructor and produce test class instances. So if you want another test class with a different type of a constructor then obviously yes you would need to write up a new data provider. 


also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider

No I don't have any ready made logic available at my hand. But if you would like to, then you could perhaps take a look at the data providers library that <a href="http://selion.io" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fselion.io\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvnXruvo1sPwT7hjMu3m5jeFLG4A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fselion.io\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvnXruvo1sPwT7hjMu3m5jeFLG4A&#39;;return true;">SeLion provides and see if you can leverage that.

To start with you would need to add a dependency on the Selion data provider

<dependency>
    <groupId>com.paypal.selion</groupId>
    <artifactId>SeLion-DataProviders</artifactId>
    <version>1.0.0</version>
</dependency>

You can then look at one of the unit tests to understand how to work with the different variants of data providers that SeLion provides by looking at the unit tests <a href="https://github.com/paypal/SeLion/tree/develop/dataproviders/src/test/java/com/paypal/selion/platform/dataprovider" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Ftree%2Fdevelop%2Fdataproviders%2Fsrc%2Ftest%2Fjava%2Fcom%2Fpaypal%2Fselion%2Fplatform%2Fdataprovider\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvhrTRiX9op8RNrkkSt6a5cx4vWg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Ftree%2Fdevelop%2Fdataproviders%2Fsrc%2Ftest%2Fjava%2Fcom%2Fpaypal%2Fselion%2Fplatform%2Fdataprovider\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEvhrTRiX9op8RNrkkSt6a5cx4vWg&#39;;return true;">here (or) looking at the samples from the SeLion archetype <a href="https://github.com/paypal/SeLion/blob/develop/archetype/src/main/resources/archetype-resources/src/test/java/sample/selion/SimpleDataDrivenTest.java" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Fblob%2Fdevelop%2Farchetype%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Ftest%2Fjava%2Fsample%2Fselion%2FSimpleDataDrivenTest.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG8JeibcXNqAAwpD3yIrcXwdZosog&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Fblob%2Fdevelop%2Farchetype%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Ftest%2Fjava%2Fsample%2Fselion%2FSimpleDataDrivenTest.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG8JeibcXNqAAwpD3yIrcXwdZosog&#39;;return true;">SimpleDataDrivenTest  and <a href="https://github.com/paypal/SeLion/blob/develop/archetype/src/main/resources/archetype-resources/src/test/java/sample/selion/SimpleDataDrivenWithSelectiveRowsTest.java" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Fblob%2Fdevelop%2Farchetype%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Ftest%2Fjava%2Fsample%2Fselion%2FSimpleDataDrivenWithSelectiveRowsTest.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE610kUF591Y__uvcaZC_F2Bpj-TA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fpaypal%2FSeLion%2Fblob%2Fdevelop%2Farchetype%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Ftest%2Fjava%2Fsample%2Fselion%2FSimpleDataDrivenWithSelectiveRowsTest.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE610kUF591Y__uvcaZC_F2Bpj-TA&#39;;return true;">SimpleDataDrivenWithSelectiveRowsTest.

For any further queries on SeLion data providers I would encourage you to post them here : <a href="https://groups.google.com/forum/#!forum/selion" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/forum/#!forum/selion&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/forum/#!forum/selion&#39;;return true;">https://groups.google.com/forum/#!forum/selion


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Wed, Jun 8, 2016 at 4:39 PM, Mahender Tirumala <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tzWeTDthAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">2mah...@...> wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser




On Wednesday, June 8, 2016 at 4:24:37 PM UTC+5:30, Mahender Tirumala wrote:
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("<a href="http://www.google.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com&#39;;return true;" onclick="this.href=&#39;http://www.google.com&#39;;return true;">http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="https://groups.google.com/group/testng-users" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tzWeTDthAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="tzWeTDthAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

⇜Krishnan Mahadevan⇝
Yanan,
Yes you should be able to use SeLion's data provider for this. Have you tried using it ? If yes, what issues do you face ? 

I would also recommend that you post SeLion's specific questions in this forum for better traction : https://groups.google.com/forum/#!forum/selion

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jan 31, 2017 at 8:01 PM, Yanan <[hidden email]> wrote:
Hi Krishnan,

I use TestNG and restAssured for REST web services testing. I use dataProvider reading test data from xls files. Do you recommend using Selion to run a single test (one row from the test data file)? If not, what do you think is the best way to do it?

Thanks,
Yanan 

On Wednesday, June 8, 2016 at 10:49:25 AM UTC-4, Krishnan wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser

​That cannot be possible because I sent you the code after personally executing it. Make sure that all your annotations are from TestNG and you aren't using the @BeforeClass and @AfterClass from JUnit. That can be the only reason why you don't see the browser cleaning up properly.


Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.
I dont quite understand what you are saying here. The data provider here provides parameters for the constructor so that TestNG may use those parameters to invoke the constructor and produce test class instances. So if you want another test class with a different type of a constructor then obviously yes you would need to write up a new data provider. 


also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider

No I don't have any ready made logic available at my hand. But if you would like to, then you could perhaps take a look at the data providers library that SeLion provides and see if you can leverage that.

To start with you would need to add a dependency on the Selion data provider

<dependency>
    <groupId>com.paypal.selion</groupId>
    <artifactId>SeLion-DataProviders</artifactId>
    <version>1.0.0</version>
</dependency>

You can then look at one of the unit tests to understand how to work with the different variants of data providers that SeLion provides by looking at the unit tests here (or) looking at the samples from the SeLion archetype SimpleDataDrivenTest  and SimpleDataDrivenWithSelectiveRowsTest.

For any further queries on SeLion data providers I would encourage you to post them here : https://groups.google.com/forum/#!forum/selion


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Jun 8, 2016 at 4:39 PM, Mahender Tirumala <[hidden email]> wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser




On Wednesday, June 8, 2016 at 4:24:37 PM UTC+5:30, Mahender Tirumala wrote:
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]om.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

Jessie
Thank you, Krishnan!

Yes, I do have one more question and I'll post it to the link you gave.

Thanks again!!

On Tue, Jan 31, 2017 at 10:46 PM, ⇜Krishnan Mahadevan⇝ <[hidden email]> wrote:
Yanan,
Yes you should be able to use SeLion's data provider for this. Have you tried using it ? If yes, what issues do you face ? 

I would also recommend that you post SeLion's specific questions in this forum for better traction : https://groups.google.com/forum/#!forum/selion

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jan 31, 2017 at 8:01 PM, Yanan <[hidden email]> wrote:
Hi Krishnan,

I use TestNG and restAssured for REST web services testing. I use dataProvider reading test data from xls files. Do you recommend using Selion to run a single test (one row from the test data file)? If not, what do you think is the best way to do it?

Thanks,
Yanan 

On Wednesday, June 8, 2016 at 10:49:25 AM UTC-4, Krishnan wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser

​That cannot be possible because I sent you the code after personally executing it. Make sure that all your annotations are from TestNG and you aren't using the @BeforeClass and @AfterClass from JUnit. That can be the only reason why you don't see the browser cleaning up properly.


Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.
I dont quite understand what you are saying here. The data provider here provides parameters for the constructor so that TestNG may use those parameters to invoke the constructor and produce test class instances. So if you want another test class with a different type of a constructor then obviously yes you would need to write up a new data provider. 


also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider

No I don't have any ready made logic available at my hand. But if you would like to, then you could perhaps take a look at the data providers library that SeLion provides and see if you can leverage that.

To start with you would need to add a dependency on the Selion data provider

<dependency>
    <groupId>com.paypal.selion</groupId>
    <artifactId>SeLion-DataProviders</artifactId>
    <version>1.0.0</version>
</dependency>

You can then look at one of the unit tests to understand how to work with the different variants of data providers that SeLion provides by looking at the unit tests here (or) looking at the samples from the SeLion archetype SimpleDataDrivenTest  and SimpleDataDrivenWithSelectiveRowsTest.

For any further queries on SeLion data providers I would encourage you to post them here : https://groups.google.com/forum/#!forum/selion


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Jun 8, 2016 at 4:39 PM, Mahender Tirumala <[hidden email]> wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser




On Wednesday, June 8, 2016 at 4:24:37 PM UTC+5:30, Mahender Tirumala wrote:
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]om.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]om.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

Jessie
In reply to this post by ⇜Krishnan Mahadevan⇝
Any help would be greatly appreciated!

On Tue, Jan 31, 2017 at 10:46 PM, ⇜Krishnan Mahadevan⇝ <[hidden email]> wrote:
Yanan,
Yes you should be able to use SeLion's data provider for this. Have you tried using it ? If yes, what issues do you face ? 

I would also recommend that you post SeLion's specific questions in this forum for better traction : https://groups.google.com/forum/#!forum/selion

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jan 31, 2017 at 8:01 PM, Yanan <[hidden email]> wrote:
Hi Krishnan,

I use TestNG and restAssured for REST web services testing. I use dataProvider reading test data from xls files. Do you recommend using Selion to run a single test (one row from the test data file)? If not, what do you think is the best way to do it?

Thanks,
Yanan 

On Wednesday, June 8, 2016 at 10:49:25 AM UTC-4, Krishnan wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser

​That cannot be possible because I sent you the code after personally executing it. Make sure that all your annotations are from TestNG and you aren't using the @BeforeClass and @AfterClass from JUnit. That can be the only reason why you don't see the browser cleaning up properly.


Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.
I dont quite understand what you are saying here. The data provider here provides parameters for the constructor so that TestNG may use those parameters to invoke the constructor and produce test class instances. So if you want another test class with a different type of a constructor then obviously yes you would need to write up a new data provider. 


also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider

No I don't have any ready made logic available at my hand. But if you would like to, then you could perhaps take a look at the data providers library that SeLion provides and see if you can leverage that.

To start with you would need to add a dependency on the Selion data provider

<dependency>
    <groupId>com.paypal.selion</groupId>
    <artifactId>SeLion-DataProviders</artifactId>
    <version>1.0.0</version>
</dependency>

You can then look at one of the unit tests to understand how to work with the different variants of data providers that SeLion provides by looking at the unit tests here (or) looking at the samples from the SeLion archetype SimpleDataDrivenTest  and SimpleDataDrivenWithSelectiveRowsTest.

For any further queries on SeLion data providers I would encourage you to post them here : https://groups.google.com/forum/#!forum/selion


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Jun 8, 2016 at 4:39 PM, Mahender Tirumala <[hidden email]> wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser




On Wednesday, June 8, 2016 at 4:24:37 PM UTC+5:30, Mahender Tirumala wrote:
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]om.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]om.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DataProvider is able to execute only single @Test only

Jessie
In reply to this post by ⇜Krishnan Mahadevan⇝
Hi Krishnan,
I resolved the problem myself.

Thanks.

On Tue, Jan 31, 2017 at 10:46 PM, ⇜Krishnan Mahadevan⇝ <[hidden email]> wrote:
Yanan,
Yes you should be able to use SeLion's data provider for this. Have you tried using it ? If yes, what issues do you face ? 

I would also recommend that you post SeLion's specific questions in this forum for better traction : https://groups.google.com/forum/#!forum/selion

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jan 31, 2017 at 8:01 PM, Yanan <[hidden email]> wrote:
Hi Krishnan,

I use TestNG and restAssured for REST web services testing. I use dataProvider reading test data from xls files. Do you recommend using Selion to run a single test (one row from the test data file)? If not, what do you think is the best way to do it?

Thanks,
Yanan 

On Wednesday, June 8, 2016 at 10:49:25 AM UTC-4, Krishnan wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser

​That cannot be possible because I sent you the code after personally executing it. Make sure that all your annotations are from TestNG and you aren't using the @BeforeClass and @AfterClass from JUnit. That can be the only reason why you don't see the browser cleaning up properly.


Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.
I dont quite understand what you are saying here. The data provider here provides parameters for the constructor so that TestNG may use those parameters to invoke the constructor and produce test class instances. So if you want another test class with a different type of a constructor then obviously yes you would need to write up a new data provider. 


also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider

No I don't have any ready made logic available at my hand. But if you would like to, then you could perhaps take a look at the data providers library that SeLion provides and see if you can leverage that.

To start with you would need to add a dependency on the Selion data provider

<dependency>
    <groupId>com.paypal.selion</groupId>
    <artifactId>SeLion-DataProviders</artifactId>
    <version>1.0.0</version>
</dependency>

You can then look at one of the unit tests to understand how to work with the different variants of data providers that SeLion provides by looking at the unit tests here (or) looking at the samples from the SeLion archetype SimpleDataDrivenTest  and SimpleDataDrivenWithSelectiveRowsTest.

For any further queries on SeLion data providers I would encourage you to post them here : https://groups.google.com/forum/#!forum/selion


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Jun 8, 2016 at 4:39 PM, Mahender Tirumala <[hidden email]> wrote:
iam getting same issue with your code, browsers are launching parallely, with out quitting any browser




On Wednesday, June 8, 2016 at 4:24:37 PM UTC+5:30, Mahender Tirumala wrote:
HI Krishnan,

Thank you, So from your code i understand dataprovider=dp works for only one class, if we want to write another class we need to create one more dp.

also can you please send xl logic if you have?...please help...actually iam struggling alot to map xl to the dataProvider




thanks
Mahender

On Wednesday, June 8, 2016 at 6:55:03 AM UTC+5:30, Krishnan wrote:
There are some issues with your code. I don't think your code is data driven in nature.

That said and done, the below sample should help you get started. Its a factory powered by a data provider. The data provider provides values to the factory and the factory uses those values to instantiate your test class objects. All the @Test annotated methods in each of your test class instance work with the parameters that were passed to its constructor via the Factory.

public class DataDrivenSample {
private RemoteWebDriver driver;
private int a;
private String b;
private boolean c;

@Factory (dataProvider = "dp")
public DataDrivenSample(Integer a, String b, Boolean c) {
this.a = a;
this.b = b;
this.c = c;
}

@BeforeClass
public void setup() {
driver = new ChromeDriver();
}

@AfterClass
public void cleanup() {
driver.quit();
}

@Test
public void testMethod() {
driver.get("http://www.google.com");
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);

}

@Test
public void anotherTestMethod() {
//Here is another test method that works on the parameters passed.
System.err.println("accessing the passed values ");
System.err.println("a = " + a);
System.err.println("b = " + b);
System.err.println("c = " + c);
}

@DataProvider (name = "dp")
public static Object[][] getData(ITestContext ctx) {
//Just showing how to access the parameters from the TestNG suite xml file.
//You can use this incase, you want to have your .xls file also passed via the suite file.
System.err.println("test name " + ctx.getName());
//Replace the below logic with your .xls reading logic.
return new Object[][] {
{10, "TestNG", true},
{20, "Selenium", false}
};
}
}

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Jun 7, 2016 at 3:02 PM, Mahender Tirumala <[hidden email]> wrote:
me (Mahender Tirumala change)
11:39 AM (3 hours ago)
Basically i have this code

public class generics {
   
    Map<String,String> dataMap=null;
    WebDriver driver;

    public generics(Map<String,String> dataMap)
    {
        this.dataMap = dataMap;
    }


   
    @Test(dataProvider="testdata",dataProviderClass = dataProvider.class)
    public void test() {
        // TODO Auto-generated method stub
            driver = new FirefoxDriver();
           
       
           
            String gmailurl= dataMap.get("Site");
            System.out.println(gmailurl);
           
            driver.navigate().to(gmailurl);
           
           

       
       
       
    }
    @Test
    public void close()
    {

        driver.quit();
    }


}

above program is datadriven tests, the xls contains 5 rows of data, i able to launch the browser 5 times, but the browsers are not closing as driver.quit i wrote in 2nd @Test, any idea how 2 @ test methods execute based on the xls data.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]om.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]om.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...