Hi, I have an AWS Amplify app that has lots of pages with collections of Amplify Cards. What I am trying to do is find each card on a page, visit the card's link, return to the original page, and repeat the process with the next card, and so forth.
So far, I've been unable to get it to work. Here is my test code:
test('dzr pages', async ({page}) => {
await login(page);
await page.goto('http://localhost:3000/DanzanRyu/Home');
await page.on('domcontentloaded', data => {});
const elements = await page.locator('.amplify-card').all()
for (let i = 0; i < elements.length; i++) {
await elements[i].click()
await page.goto('http://localhost:3000/DanzanRyu/Home');
}
});
Attached is also some snapshots of the page info.
TIA, -T
This thread is trying to answer question "How can I loop through multiple links on an AWS Amplify app to check for broken links?"
@tennis6164 I can help you with that my the code should like this ` test('dzr pages', async ({page}) => { await login(page); await page.goto('http://localhost:3000/DanzanRyu/Home');
const elements = await page.locator('.amplify-card').all()
for (let i = 0; i < elements.length; i++) { await elements[i].click();
// Wait for navigation to complete.
await page.waitForLoadState('networkidle');
// Check that a valid response was received.
page.on('response', response => {
expect(response.status()).toBe(200);
});
// Go back to the home page for the next iteration.
await page.goto('http://localhost:3000/DanzanRyu/Home');
} });
`
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].