in playwright locator in python I can use timeout directly on locators:
loggedin = page.locator('//h1[@class="page-title" and (text()="Your keys" or text()="Dine nøkler")]').is_visible(timeout=1000)
It returns a bool and no exception after 1 sec
How can I do the same timeout in K6 Browser, isVisible() have no timeout?
try {
let loggedin = await page.locator('//h1[@page-title=" and (text()="Your keys" or text()="Dine nøkler")]').isVisible();
}
catch (e) {
console.log("returns a promise after 30sec");
}
Hey @mortenb123,
Unfortunately, k6-browser Locator.isVisible
doesn’t support adding options. Could you please create an issue on our Github here?
Thanks!
Seems like isVisible() in javascript do not have a timeout, how can I set timeouts then:
or something like:
async function myVisible(selector: string, timeout: number) {
try {
await page.waitForSelector(selector, { timeout, state: 'visible' })
return true;
} catch (err) {
return false;
}
};
1 Like
Yes, you can also use locator.waitFor
before working with the element.
1 Like