NightwatchJS从不运行网址

时间:2017-01-22 13:55:30

标签: selenium selenium-webdriver nightwatch.js

我一直在尝试配置夜视仪来执行一些单元测试任务。

Selenium服务器和chrome正在运行但是我从来没有得到实际加载在chrome中的url栏中的url,因此什么都没有出现,我只是得到一个带有"数据的空白页面;"在chrome的url中(使用chromedirver)

如果有人可以提供帮助,请点击此处

{
  "src_folders" : ["test"],
  "output_folder" : "reports",
  "custom_assertions_path" : "",
  "globals_path" : "",
  "live_output" : true,
  "parallel_process_delay" : 10,
  "disable_colors": false,
  "test_workers" : false,

  "selenium" : {
    "start_process" : true,
    "server_path" : "bin/selenium.jar",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "bin/chromedriver",
      "webdriver.firefox.profile" : "bin/geckodriver"
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "test_link.com",
      "selenium_host" : "127.0.0.1",
      "selenium_port" : 4444,
      "silent" : true,
      "disable_colors": false,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities" : {
        "browserName" : "chrome",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true
      }
    },

    "saucelabs" : {
      "selenium_host" : "ondemand.saucelabs.com",
      "selenium_port" : 80,
      "username" : "${SAUCE_USERNAME}",
      "access_key" : "${SAUCE_ACCESS_KEY}",
      "use_ssl" : false,
      "silent" : true,
      "output" : true,
      "screenshots" : {
        "enabled" : false,
        "on_failure" : true,
        "path" : ""
      },
      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "firefox"
      },
      "globals" : {
        "myGlobal" : "some_sauce_global"
      },
      "selenium" : {
        "start_process" : false
      }
    },


    "testingbot" : {
      "selenium_host" : "hub.testingbot.com",
      "selenium_port" : 80,
      "apiKey" : "${TB_KEY}",
      "apiSecret" : "${TB_SECRET}",
      "silent" : true,
      "output" : true,
      "screenshots" : {
        "enabled" : false,
        "on_failure" : true,
        "path" : ""
      },
      "desiredCapabilities": {
        "name" : "test-example",
        "browserName": "firefox"
      },
      "selenium" : {
        "start_process" : false
      }
    }
  }
}

这是我的考试

module.exports = {
  'Tracking the website': function (client) 

    client
      .url(client.launch_url)
      .getValue('#id1', function(result){
        console.log("================================");
        console.log("value " + result.value);
        console.log("================================");
      })
      .end();
  }
};

1 个答案:

答案 0 :(得分:1)

那是因为您的launch_url不包含要使用的协议。

尝试使用"launch_url" : "http://www.google.com"代替"launch_url" : "www.google.com"