Javascript Nightwatchjs获取多个输入的值
有没有办法使用nightwatchjs获取多个输入的值 我需要同时测试几个输入的值Javascript Nightwatchjs获取多个输入的值,javascript,selenium,nightwatch.js,Javascript,Selenium,Nightwatch.js,有没有办法使用nightwatchjs获取多个输入的值 我需要同时测试几个输入的值 提前感谢。您可以使用getText或getValue方法,例如: this.demoTest = function (browser) { browser.getText("#main ul li a.first", function(result) { this.assert.equal(typeof result, "object"); this.assert.equal(result.s
提前感谢。您可以使用getText或getValue方法,例如:
this.demoTest = function (browser) {
browser.getText("#main ul li a.first", function(result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
this.assert.equal(result.value, "nightwatchjs.org");
});
};
this.demoTest = function (browser) {
browser.getValue("form.login input[type=text]", function(result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
this.assert.equal(result.value, "enter username");
});
};
这些api文档:您可以使用getText或getValue方法,例如:
this.demoTest = function (browser) {
browser.getText("#main ul li a.first", function(result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
this.assert.equal(result.value, "nightwatchjs.org");
});
};
this.demoTest = function (browser) {
browser.getValue("form.login input[type=text]", function(result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
this.assert.equal(result.value, "enter username");
});
};
有api文档:是的,您可以获得多个输入值: 第一个选项是回调(不推荐): 其次,您可以使用文档中的perform()api(推荐):
这是来自nightwatch的文档是的,您可以获得多个输入值: 第一个选项是回调(不推荐): 其次,您可以使用文档中的perform()api(推荐): 我是夜视的医生
var text, text2, text3;
browser
.getValue('#input', function (result) {
text = result.value;
browser.getValue('#inputField2', function (result) {
text2 = result.value;
});
})
.perform(function () {
browser.getValue('#inputField3', function (result) {
console.log(text2, text 1) // they do exist here
text3 = result.value;
});
});