'Dynamically grab data for data driven tests in CodeceptJs
I want to run data driven tests in CodeceptJs, but I don't have a fixed data set. I have to grab the data before the test. I am on a webpage, that has a table and inside that table I find my data. I want to grab it and then run the test with whatever data I got. I tried something like this, but it didn't work:
let data = new DataTable(['id']);
BeforeSuite(async ({I}) => {
I.amOnPage('my_portalpage');
const ids = await I.grabAttributeFromAll('.data', 'data-id');
ids.map((id) => {
data.add([id]);
})
});
Data(data).Scenario('Run tests using the data', async ({ I, current }) => {
// do stuff for current.id
})
The result is that the scenarios just don't run. I tried to grab the data inside a scenario, with the same result. I guess the data has to be fully defined right at the beginning, but how can I do that? There is no API I can use to get the data, I have to go to the page and grab it.
Thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
