In WebdriverJS is there anyway to create environment variable programmaticaly and use that variable in my code. I want to store the JSON response in the environment variable and assert the data in the environment variable against expected result.
Asked
Active
Viewed 66 times
0
-
1Please provide more details. whats the expected result and json response that you are getting? why you need it? – Abhishek_Mishra Sep 05 '18 at 07:07
-
In my application I run a search that triggers REST service and returns multiple results in the form of JSON. I want to validate that each response contains the word I searched for. I see the response using Chrome's developer tool and manually I can create environment variable and query for the expected result. However, thousands of words that I need to search for. So I need to automate this. One way to test this is by testing the API itself through Postman. But we are expected to test this through UI so need some solution in WebdriverJS. – Zeus Sep 05 '18 at 14:12
-
This might be of help to you: https://stackoverflow.com/questions/22312671/node-js-setting-environment-variables – PJAutomator Sep 05 '18 at 14:15
-
1@Zeus : given your requirement you should hit the API call and compare the response to what you get on UI after search. – Abhishek_Mishra Sep 05 '18 at 19:48
-
@Abhishek_Mishra: Problem with making API call is that everytime I make a API call we get separate records. Which is by design. So I cannot compare the result with API. Hence, was looking for a way to compare it with response that I see in Chrome Developer tool. – Zeus Sep 06 '18 at 18:15