【问题标题】:How do I add a message to browser.wait() without changing the default timeout?如何在不更改默认超时的情况下向 browser.wait() 添加消息?
【发布时间】:2020-07-03 16:22:33
【问题描述】:

我有一些代码

browser.wait(ExpectedConditions.presenceOf(elementName));

这通常会失败,只是说“预期为真为假”。这让我很头疼。当它失败时,我希望它给我一个更具描述性的原因,为什么它与 elementName 一起失败。

所以我想更改它以添加消息。 browser.wait 定义为:

wait(condition: WebElementCondition, opt_timeout?: number, opt_message?: string): WebElementPromise;

所以我可以这样做:

browser.wait(ExpectedConditions.presenceOf(element), 0, `Expected presence of ${elementName}`);

但我不想在不需要时更改 opt_timeout。有什么方法可以在不通过 opt_timeout 的情况下传递 opt_message?

【问题讨论】:

    标签: angular typescript selenium protractor


    【解决方案1】:
    browser.wait(ExpectedConditions.presenceOf(element), undefined, `Expected presence of ${elementName}`);
    

    您可以在第二个参数中传递 undefined。使用 undefined 不会改变默认超时时间。

    这很好用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-10
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 2014-10-13
      • 2011-01-21
      相关资源
      最近更新 更多