You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am trying data driven approach in webdriverIO , I have a test data in json file and using forEach to fetch it and test for the concerned test steps. However, its working for 1st data set and after that webdriver instantiation is not happening for 2nd data set and its failing.
Here is the scenario.
1.json file 3 data sets
2.I have created a spec file, has a logic to open the application and login to it with the json file test data.
3.When I executed the spec, its perfectly worked for 1st data set and logged to the App, however its failed with an error for the 2nd data set/run as webdriver couldn't recognize the locator for UserID textBox, bcz previous run window/browser has not closed to login again.
Error: Can't call setValue on element with selector "//input[@id="txtuid"]" because element wasn't found
error occurring bcz of previous rub browser/ window has not closed to login again for the 2nd run, hence element couldn't find for the 2nd run.
spec:
const ff =require('fs')
let tdata =JSON.parse(fs.readFileSync('../data.json'))
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I am trying data driven approach in webdriverIO , I have a test data in json file and using forEach to fetch it and test for the concerned test steps. However, its working for 1st data set and after that webdriver instantiation is not happening for 2nd data set and its failing.
Here is the scenario.
1.json file 3 data sets
2.I have created a spec file, has a logic to open the application and login to it with the json file test data.
3.When I executed the spec, its perfectly worked for 1st data set and logged to the App, however its failed with an error for the 2nd data set/run as webdriver couldn't recognize the locator for UserID textBox, bcz previous run window/browser has not closed to login again.
Error: Can't call setValue on element with selector "//input[@id="txtuid"]" because element wasn't found
error occurring bcz of previous rub browser/ window has not closed to login again for the 2nd run, hence element couldn't find for the 2nd run.
spec:
const ff =require('fs')
let tdata =JSON.parse(fs.readFileSync('../data.json'))
describe('Login',async()=>
{
tdata.forEach(function(data) {
it('login Test',async()=>
{
})
})
})
json data file:
[
{
"UserID":"admin",
"Pass":"admin"
},
{
"UserID":"admin1",
"Pass":"admin1"
},
{
"UserID":"admin3",
"Pass":"admin3"
},
]
Beta Was this translation helpful? Give feedback.
All reactions