【问题标题】:How to get text from alertbox in spectron-mocha-webdiverio如何从 spectron-mocha-webdriverio 中的警报框中获取文本
【发布时间】:2017-10-03 18:21:01
【问题描述】:

我正在使用 Spectron 测试我的电子应用程序。 我正在尝试从警报框中获取文本,但出现错误。 我想从警报中获取文本,如果这是预期的,则接受它。

测试:

it('Check alert message', function() {
        return this.app.client
            .waitForExist('#associates', 20000).should.eventually.equal(true)
            .click('#pq-associates')
            .click('#submit-selection')
            .alertText().should.eventually.equal("You have to select any one")
            .should.eventually.exist
    });

我收到以下错误

no alert open
Error: An attempt was made to operate on a modal dialog when one was not open.

但我可以看到警报。

【问题讨论】:

    标签: electron webdriver-io spectron


    【解决方案1】:

    正如与 WebDriverio 社区讨论的那样,很难处理默认的 alert() 函数。他们建议实现我自己的类似 alert() 的功能。所以我使用https://github.com/limonte/sweetalert2 实现了自己的警报,并且测试工作正常。

    社区讨论:https://gitter.im/webdriverio/webdriverio/archives/2017/10/04

    Spectron 问题:https://github.com/electron/spectron/issues/23

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 2011-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      • 2017-02-26
      相关资源
      最近更新 更多