为什么夜班人员没有选择我的浏览器配置

时间:2017-01-08 01:45:19

标签: nightwatch.js

我正在使用夜间测试来测试网站。以下是我的配置文件。我想使用phantomjs作为浏览器,因此无需打开浏览器即可运行。但是当我使用nightwatch -c integration-tests/nightwatch.json命令运行测试时,它总是打开我的chrome浏览器。我试图修改browserName的值,发现无论我输入什么都没有任何效果。我的配置有什么问题吗?

{
  "src_folders": [
    "./integration-tests/tests"
  ],
  "output_folder": "./integration-tests/reports",
  "custom_commands_path": "",
  "custom_assertions_path": "",
  "page_objects_path": "",
  "globals_path": "",
  "selenium": {
    "start_process": false
  },
  "test_settings": {
    "default": {
      "launch_url": "http://localhost:9091",
      "selenium_port": 9515,
      "selenium_host": "localhost",
      "default_path_prefix": "",
      "silent": true,
      "screenshots": {
        "enabled": false,
        "path": ""
      },
      "desiredCapabilities": {
        "browserName": "phantomjs",
        "javascriptEnabled" : true,
        "phantomjs.binary.path" :"node_modules/phantomjs",
        "phantomjs.cli.args" : []
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

您需要更改PhantomJS报告的userAgent。

<script src="https://unpkg.com/@reactivex/rxjs@5.0.0-beta.7/dist/global/Rx.umd.js"></script>
  <select id="testDD">
    <option value="">Select to filter</option>
    <option value="local">Local</option>
    <option value="international">Internationl</option>
  </select>
  
  <h2>filtered resuls</h2>
  <div id="list">
    <!-- List Items to be generated from #testDD value -->
  </div>
  

设置{object}

     

userAgent 定义网页请求资源时发送给服务器的用户代理。

     

来源:http://phantomjs.org/api/webpage/property/settings.html

如果您需要更多示例:

{
  "src_folders": [
    "./integration-tests/tests"
  ],
  "output_folder": "./integration-tests/reports",
  "custom_commands_path": "",
  "custom_assertions_path": "",
  "page_objects_path": "",
  "globals_path": "",
  "selenium": {
    "start_process": false
  },
  "test_settings": {
    "default": {
      "launch_url": "http://localhost:9091",
      "selenium_port": 9515,
      "selenium_host": "localhost",
      "default_path_prefix": "",
      "silent": true,
      "screenshots": {
        "enabled": false,
        "path": ""
      },
      "desiredCapabilities": {
        "browserName": "phantomjs",
        "javascriptEnabled" : true,
        "phantomjs.binary.path" :"node_modules/phantomjs",
        "phantomjs.cli.args" : [],
        "phantomjs.page.settings.userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36"
      }
    }
  }
}