Protractor Promise 回调不显示内容。如何调用退回项目的方法?
Protractor Promise callbacks not showing content. How do I call the methods of the returned item?
在下面的代码中,当调试器被命中时,thing/item 的值什么都不显示(见图)..
it('CheckAllLinks:', function () {
browser.ignoreSynchronization = true;
browser
.findElements(by.tagName('a'))
.then(function (items) {
items.forEach(function (item) {
var thing = item;
debugger;
});
});
});
例如,对这些方法的任何调用仅 returns 使用直接 window 在 Visual Studio 中的三个点。 (...);
我知道这是一个承诺,但不明白如何使用任何方法来验证内容并单击 link...
发现答案与这些调用本身就是承诺有关。当 .then 语句被命中时,承诺就会实现。在下面的示例中,承诺了两件事,每个 link 的文本和 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;
});
});
});
});
});
在下面的代码中,当调试器被命中时,thing/item 的值什么都不显示(见图)..
it('CheckAllLinks:', function () {
browser.ignoreSynchronization = true;
browser
.findElements(by.tagName('a'))
.then(function (items) {
items.forEach(function (item) {
var thing = item;
debugger;
});
});
});
例如,对这些方法的任何调用仅 returns 使用直接 window 在 Visual Studio 中的三个点。 (...);
我知道这是一个承诺,但不明白如何使用任何方法来验证内容并单击 link...
发现答案与这些调用本身就是承诺有关。当 .then 语句被命中时,承诺就会实现。在下面的示例中,承诺了两件事,每个 link 的文本和 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;
});
});
});
});
});