gpt4 book ai didi

electron - 如何从Spectron-Mocha-WebDriverio中的警报框中获取文本

转载 作者:行者123 更新时间:2023-12-03 12:21:23 25 4
gpt4 key购买 nike

我正在使用Spectron测试我的 Electron 应用程序。
我正在尝试从Alertbox获取文本,但出现错误。
我想从警报中获取文本,如果可以预期的话,请接受它。

测试 :

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.

但是我可以看到警报。

最佳答案

正如与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

关于electron - 如何从Spectron-Mocha-WebDriverio中的警报框中获取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46551003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com