Hi Elastic,
Need help on how can I create a script on my use case where, if we detect there is Error display in the page, we want to note it as Fail and not Complete as in success.
For example, below is the sample of error :
Below is the script that I create but its not working, it still showing as Success :
step('Error Checking', async () => {
try{
await page.goto('https://****.com');
await page.locator('[placeholder="Search From Here"]').click();
await page.locator('[placeholder="Search From Here"]').fill('test');
await Promise.all([
page.waitForNavigation(),
page.locator('[placeholder="Search From Here"]').press('Enter')
]);
}
catch(e){
await expect(page.getByText('Error', { exact: true })).toBeVisible();
console.log("Closed the browser")
await browser.close();
throw e;
}
});
I try to do the error checking by try and catch, but its not working.
It still detect as Complete :
To give you context on the script, I want to check if user did the searching, for example if 'test' query has been input, will it throw error on whether the server is error.
Not sure if I did the correct way but the wording error text is within
html tag.Below is the inspect of the page :
Need guidance on this thanks!