在下面的代码中,当调试器被点击时,事物/项目的值不显示任何内容(参见图片)..
it('CheckAllLinks:', function () {
browser.ignoreSynchronization = true;
browser
.findElements(by.tagName('a'))
.then(function (items) {
items.forEach(function (item) {
var thing = item;
debugger;
});
});
});
例如,使用 Visual Studio 中的即时窗口对这些方法的任何调用仅返回三个点。 (...);
我意识到这是一个 promise ,但不明白如何使用任何方法来验证内容并单击链接...
最佳答案
发现答案与这些调用本身就是 promise 这一事实有关。当 .then 语句被命中时, promise 就会得到履行。在下面的示例中, promise 了两件事:每个链接的文本和 href。
it('CheckAllLinks:', function () {
browser.ignoreSynchronization = true;
browser
.findElements(by.tagName('a'))
.then(function (items) {
items.forEach(function (item, i) {
var test = item.getText().then(function (text) {
item.getAttribute('href').then(function (href) {
debugger;
});
});
});
});
});
关于javascript - Protractor Promise 回调不显示内容。如何调用返回项的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30039207/