gpt4 book ai didi

javascript - 未调用 promise 中的函数 it()

转载 作者:行者123 更新时间:2023-11-30 11:43:50 24 4
gpt4 key购买 nike

我得到了一个元素列表,其中一些是不可见的。我想单击那些可见的,然后检查它们是否有新类。

var tabsExpandable = $$("my-nav-bar .my-nav-bar-column-item.expandable");

tabsExpandable.each(function (tab) {
tab.isDisplayed()
.then(function (isVisible) {
if (!isVisible) {
return "not visible";
}

tab.click();

it("should expand a visible tab", function () {
expect(tab.getAttribute("class")).toContain("expanded");
});

});
});

但是函数 it("should expand...") 没有注册,因此处理程序没有被调用。如何解决这个问题?

最佳答案

你应该把it(...)放在第一位

it("should expand a visible tab", function () {
var tabsExpandable = $$("my-nav-bar .my-nav-bar-column-item.expandable");

tabsExpandable.each(function (tab) {
tab.isDisplayed()
.then(function (isVisible) {
if (!isVisible) {
return "not visible";
}

tab.click();
expect(tab.getAttribute("class")).toContain("expanded");


});
});
});

关于javascript - 未调用 promise 中的函数 it(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41682789/

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