Questions tagged [testng-dataprovider]

TestNG @DataProvider annotation

Refers to @DataProvider, a TestNG annotation that allows combinations of parameters (test data) to be automatically injected into your test methods. It's encountered often with Selenium.

Related tags :

Reference links :

449 questions
2
votes
3 answers

Using Array as Parameter for Test Method

Commonly the parameters for the test method are as follows @Test //Test method (dataProvider="login") public void TestCase1(String field1, String…
2
votes
1 answer

TestNG: Specific data from DataProvider for specific test methods

Is it possible to specify data from DataProvider for each test method. I've made something like this. @DataProvider(name = "loginData") public Object[][] getData(Method m) { if (m.getName().equalsIgnoreCase("testValidLogin")) { return…
2
votes
0 answers

Unable to return Object[] from DataProvider

I tried returning a single dimensional Object[] from dataProvider and it worked for me. But the same code is not working in my office environment.What would be the issue? I am using TestNG 6.13.1 @DataProvider(name = "Data") public Object[]…
2
votes
1 answer

How to override the index.html report in testNG

I have a scenario where I need to add some custom messages into index.html testNG report. Is there any way to do that? I just created a custom annotation which I want to publish into index.html testNG report like DataProvider did. I have been tried…
ArrchanaMohan
  • 2,314
  • 4
  • 36
  • 84
2
votes
2 answers

How to send rows with flag to dataprovider

I am using below code to pass the rows to data provider with flag M, But my test is running for all the rows. File filpath = new File(FilePath); FileInputStream ExcelFile = new FileInputStrea(filpath); ExcelWBook = new…
Critica
  • 87
  • 10
2
votes
1 answer

How to run multiple test cases in testng with different set of test data from excel file?

I have following testng.xml, my project contains multiple classes each with one @Test testNG Method and its relevant Data Provider (means class I1_DoLoginTest contain one method and its dataprovider, class I2_CreateScenarioTest contain one method…
2
votes
1 answer

Multiple values for parameters in testng.xml (without using dataProvider)

I want to run my test case multiple times with different values of parameters. Is it possible using testng.xml and @Parameters annotation? Eg.
arctic_monkey
  • 153
  • 2
  • 4
  • 16
2
votes
1 answer

Reading data from json file for data provider in testng

I want to provide data in my dataProvider using json file. Please suggest the best approach for it, (in java.) eg. Json file { "dataSet": [ { "testCase": "Verify error message on wrong userName", "username": "test", …
arctic_monkey
  • 153
  • 2
  • 4
  • 16
2
votes
1 answer

how to pass data to onTestSuccess method in Listener class of TESTNG for each iteration from @Test method used dataprovider

, i have a @Test method with dataprovider , i have a Listener.class , my target is that when my @Test method is success, the status of case in testrail is setted as "Passed" automatically in onTestSuccess Method of Listener class , this process is…
2
votes
1 answer

TestNg Annotation Syntax

I started learning TestNG but i got stuck so i need little help related to syntax I have already using annotation dataProvider @Test(dataProvider="getdata") public void testCase02(String text1,String text2){ System.out.println("I m in second…
shubham bansal
  • 796
  • 1
  • 5
  • 13
2
votes
1 answer

TestNG Parallel execution with selenium

If i need to run same one method with two different browser at the same time then how will i implement it? For example: public class AppTest2{ @parameters("browser") @Test(dataProvider="loginData") public void login(String userName , String…
user1459497
  • 659
  • 2
  • 9
  • 18
2
votes
3 answers

How to run Cucumber scenario in different @Test or xml with Cucumber & TestNG

I'm looking at running Cucumber tests with TestNG. However I am having a issue where all my Scenario are running as one TestNG @Test session. Is there a way to run each Scenario as a separate @Test sessions? Here is my TestNG xml:
2
votes
0 answers

How to get list of all tests in a package (and ones with data provider multiple times)

We are trying to create custom report about our test execution and for this we'd like to have list of all the tests we have. We tried implementing IMethodInterceptor interface and adding each test into list in intercept method. This worked partly,…
burm
  • 93
  • 11
2
votes
2 answers

Stale Element Reference exception with Selenium Web Driver parallel execution of test cases

This is my class containing Test method f() which I want to execute in parallel. Data provider gives input to test method. public class DemoTest { private WebDriver driver; @Test(dataProvider = "dp") public void f(Integer n, String s) { try…
Grishma Oswal
  • 303
  • 1
  • 7
  • 22
2
votes
2 answers

can dataprovider pass data to @BeforeTest

I want to know if dataprovider can pass data to @BeforeTest along with @Test. I am working on script where in i want pass some data to @BeforeTest and perform some operations. If its possible kindly share the logic. Thank you
autoD
  • 109
  • 2
  • 14