Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Nightwatchjs获取多个输入的值_Javascript_Selenium_Nightwatch.js - Fatal编程技术网

Javascript 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

有没有办法使用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.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;
    });
  });