无法使用javascript在nightwatch中使用setValue将文本输入元素

时间:2017-09-29 02:28:01

标签: javascript nightwatch.js

这是我的 nightwatch.conf.js

{
  "src_folders" : ["D:/project/tests"],
  "output_folder" : "D:/project/reports",
  "custom_commands_path" : "",
  "custom_assertions_path" : "",
  "page_objects_path" : "",
  "globals_path" : "",

  "selenium" : {
    "start_process" : true,
    "server_path" : "D:/project/selenium/seleniumstandalone.jar",
    "log_path" : "",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "D:/project/lib/chromedriver.exe",
      "webdriver.gecko.driver": "D:/project/lib/geckodriver.exe"
    }
  },

  "test_settings" : {
    "default" : {

       "browserName" : "firefox",

      "javascriptEnabled" : true,
        "acceptSslCerts": true
      }


    }
  }

这是测试中的代码:

module.exports = {
  'Demo test Google' : function (client) {
    client
      .url('http://www.google.com')
      .waitForElementPresent('body', 1000)
      .pause(1000)
      .setValue('input[type=text]', 'nightwatch')
      .waitForElementPresent('button[name=btnG]', 1000)
      .click('button[name=btnG]')
      .pause(1000)

      .end();
  }
};

测试结果:

D:\ project>节点nightwatch.js -t tests / p.js

启动selenium服务器...已启动 - PID:2772 [P]测试套件==================

正在运行:演示Google √元素在20毫秒后出现。 √元素在30毫秒后出现。 好。 2个断言通过。 (15.585s)

所有测试都已通过,但 setValue()未在元素中输入文字。

0 个答案:

没有答案
相关问题