簡體   English   中英

protractor - browser.wait() promise 不工作

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM