[英]protractor - browser.wait() promise is not working
我正在尝试使用 brower.wait 验证页面的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()}`);
});
};
我应该怎么做才能在这两种情况下打印日志? 谢谢
尝试这个
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}`);
};
但请确保您使用await
调用它
await temp('https://your.url');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.