I am trying to verify the url of the page using brower.wait
. This function prints logs when promise is fulfilled by condition EC.urlIs(expectedUrl)
with truthy, however, if EC.urlIs(expectedUrl)
promise rejects then control doesn't go inside then
hence doesn't print logs.
const temp = async (expectedUrl) => {
await browser.wait(EC.urlIs(expectedUrl), 1000).then(async res => {
log.info(`expected url: ${expectedUrl}`);
log.info(`current url: ${await browser.getCurrentUrl()}`);
});
};
what should i do to print logs in both condition? Thanks
try this
const temp = async (expectedUrl) => {
await browser.wait(EC.urlIs(expectedUrl), 1000);
let text = await browser.getCurrentUrl();
log.info(`expected url: ${expectedUrl}`);
log.info(`current url: ${text}`);
};
but make sure you call it with await
await temp('https://your.url');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.