gpt4 book ai didi

selenium - 浏览器切换处理 Phantomjs 问题

转载 作者:行者123 更新时间:2023-11-28 20:54:29 25 4
gpt4 key购买 nike

我将 Protractor 与 cucumber 一起使用,每当需要使用 phantomjs 在浏览器选项卡之间切换时,它就会挂起而不会出现任何错误消息。然而,同样的步骤适用于 Chrome 浏览器。这是为什么?我的步骤如下

this.Then(/^the page url hash should be "([^"]*)"$/, function (arg1, callback) {
browser.getAllWindowHandles().then(function (handles) {
newWindowHandle = handles[2];
browser.switchTo().window(newWindowHandle).then(function () {
expect(browser.driver.getCurrentUrl()).to.eventually.contain(arg1).and.notify(callback);
});
});

最佳答案

好吧,显然问题出在 callback 上。当我稍微修改上面的代码时,即使在 phantomjs 中它也能像魅力一样工作!

this.Then(/^the page url hash should be "([^"]*)"$/, function (arg1, callback) {
browser.getAllWindowHandles().then(function (handles) {
newWindowHandle = handles[2];
browser.switchTo().window(newWindowHandle).then(function () {
expect(browser.getCurrentUrl()).to.eventually.contain(arg1);
});
});
callback();

});

关于selenium - 浏览器切换处理 Phantomjs 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30871043/

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