有了承諾的網絡驅動程序,我想檢查頁面上是否存在元素,然後登錄,否則繼續使用承諾鏈。如何做到有條件的瀏覽器與實習生互動
由於https://github.com/theintern/intern/issues/14,此刻不可能嗎?
有了承諾的網絡驅動程序,我想檢查頁面上是否存在元素,然後登錄,否則繼續使用承諾鏈。如何做到有條件的瀏覽器與實習生互動
由於https://github.com/theintern/intern/issues/14,此刻不可能嗎?
在實習2,只需使用普通find
命令:
var remote = this.remote;
remote.get(url)
.findById('foo')
.then(function (element) {
// exists
}, function() {
// does not exist
});
在實習1,如果你需要條件的分支,你需要停下來,根據您的檢查結果添加新指令。
var remote = this.remote;
remote.get(url)
.elementByIdIfExists('foo')
.then(function (element) {
if (element) {
remote.clickElement()
.type('foo');
// ...etc.
}
});
這應該實習生1.1只工作,如果你是當有未決沒有其他已經存在的命令添加新命令來遠程諾言鏈。實習生1.2將包含消除此限制的改進。這是問題#14。
此問題也有關:https://github.com/theintern/intern/issues/53 – jonperl