Appreciate Author, video posted is very clean and descriptive
@sdetpavan3 жыл бұрын
Glad it was helpful!
@AbidHussain-no6vd3 жыл бұрын
Thanks for this important concept, where can learn @DataProvider also in depth.
@uigreseu5756 Жыл бұрын
Hello. Why I'm not able to use String[] . It tells me that I should use Object[][]. The problem is that I try to reproduce the code from your video but it asks me to make return type Object[][]. Why? I would like to use String [] like in your video
@jeyasankara4781 Жыл бұрын
Thanks for your teaching sir, and I have the question that.... Is it possible to read the data from Excel then convert as json and pass to our specific function by single code? I have solved read the data from Excel file and convert as JSON file. But I need to pass the converted json data into specific function using dataprovider in a single step.
@abhijitkumar8615 Жыл бұрын
I have a different scenario here, i have userdata in a json file and all these datas are unique. I want to pass them as a parameter in different test cases under @test method. In your eg you are passing same data everytime, but I want to pass first array data in first test case, 2nd array data in 2nd test case and so on. Note. The test cases are individual classes. Can you please let me know how to achieve that
@olegs30364 жыл бұрын
Hi @SDET, thank you for the video. I do everything by video and when I set the String type in the method - Java swears and offers to set the Object type, why?
@Kumarkumar-gf3kk3 жыл бұрын
this the method i created as per video i run the code with out any errors @DataProvider(name = "dp") public String[] readJson() { // Here we are going to use simple json jar // We need to create JSon praser object to read json data JSONParser jsonParser = new JSONParser(); FileReader reader = null; try { reader = new FileReader(".\\jsonfiles\\testdata.json"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } String[] arr = null; try { Object obj = jsonParser.parse(reader); //Cast the object to JSOn Object JSONObject userloginsJsonobj = (JSONObject) obj; //Convert to user JSON Array JSONArray userLoginArray = (JSONArray)userloginsJsonobj.get("userlogins"); //create a java array arr = new String[userLoginArray.size()]; // Iterate through user Jsaon array for (int i = 0; i < userLoginArray.size(); i++) { JSONObject users = (JSONObject) userLoginArray.get(i); String user = (String) users.get("username"); String pwd = (String) users.get("password"); arr[i] = user + "," + pwd; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return arr; } }
@jayanthyadav43543 жыл бұрын
Geting error java.lang.ClassCastException: class org.json.simple.JSONArray cannot be cast to class org.json.JSONObject (org.json.simple.JSONArray and org.json.JSONObject are in unnamed module of loader 'app') "
@bonybaby19124 жыл бұрын
Which is better for data driven testing, Excel or JSON? what are the advantages and disadvantages of JSON over excel for data driven testing?
@manishbhatia27244 жыл бұрын
JSON has mainly advantages rather than disadvantes 1.JSON is more lightweight 2.No need to install seperate software to read excels.This is specifically useful when running scripts on server. 3.No more complicated code. In excel we need to provide following hiearchy File,Sheet,rownum/colnum,cell
@praveenmaddi49034 жыл бұрын
When I executed same code , i am getting Below error . Tried in Google also but did get anything. Please help me to sort out the issue Error Message: org.json.simple.parser.ParseException must return either Object[] [] or Iterator[], not class [Ljava.lang.String;
@mohammedzakaria87834 жыл бұрын
Can anyone pls explain why its showing the above error? any solution? Thanks
@priyankasahu8780 Жыл бұрын
Thank you.This is very helpful
@sdetpavan Жыл бұрын
Glad it was helpful!
@azharuddinkhan23174 жыл бұрын
@SDET , how your code is reading single dimension array by using data provider, as I am aware testng data provider needs 2 D Array Object ? Please clarify
@amlam56854 жыл бұрын
The return type of data provider could be any object [],[][].[][][].., it is up to you what to wanna use, also it depends on your logic and the complicity of the data you are dealing with. Here it is easy to use an array to retrieve data from JsonArray and return it with username and password combined.
@AbidHussain-no6vd3 жыл бұрын
2D array also ARRAY only ( Array of Array) . if u think in depth here readjson data method is returning array , but again split method is applied on element of returned array , which returning array again .
@sebastus273 жыл бұрын
Mr SDET, I have a question, what does name mean from the @DataProvider(name="dp")?
@Kumarkumar-gf3kk3 жыл бұрын
@DataProvider(name="dp")? dp is the identifier(name) of DataProider .you can give any value as name for the data provider @DataProvider(name="")?
@sebastus273 жыл бұрын
I have these errors Cannot resolve method 'dataProvider' and Cannot resolve method 'name'.
@commonman83703 жыл бұрын
Now a days the problem how to approach for a solution. I think i have got some idea now. Thanks
@dibyajyotimohanty92523 жыл бұрын
Hii sdet can you plz explain how to convert nested and complex json file into csv by using java code.its really helpful for me.
@sharana_rani3 жыл бұрын
Hi If I don't define my data into Jsonfile under an array and I defined all my data in single object. how do I read the file data in testng?
@Kumarkumar-gf3kk3 жыл бұрын
can be achieved .only thing is one need to get familiar with Jason parsing (simple json api)
@sharana_rani3 жыл бұрын
@@Kumarkumar-gf3kk hi thanks I have got hands on that long back
@sebastus273 жыл бұрын
Now, I have this problem: Data provider must return Object[][] or Iterator
@gomathisubramanian82 жыл бұрын
+1 while we try the same from intellij. Can you please provide us how to resolve the issue @ SDET- QA Automation Techie
@olegs30364 жыл бұрын
org.testng.internal.reflect.MethodMatcherException: [public void ReadJSONFile.test(java.lang.String,java.lang.String)] has no parameters defined but was found to be using a data provider (either explicitly specified or inherited from class level annotation). Data provider mismatch Method: test([Parameter{index=0, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=1, type=java.lang.String, declaredAnnotations=[]}]) Arguments: [(java.lang.String) null,1234433]
@pamci2844 жыл бұрын
is this issue resolved?
@chagantisivakrishna99792 жыл бұрын
How to deal with , In case if we are getting the same kind of response from a webpage , for example { "flights": [ { "code": "A70567", "description": "from bombay to delhi" } ] }