2017-01-08 4 views
0

ウェブサイトのテストに夜間監視を使用しています。以下は私の設定ファイルです。私はブラウザとしてphantomjsを使用したいので、ブラウザを開かずに実行することができます。しかし、私がnightwatch -c integration-tests/nightwatch.jsonコマンドでテストを実行すると、常にクロムブラウザが開きます。そして、私は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" : [] 
     } 
    } 
    } 
} 

答えて

0

PhantomJSが報告していたuserAgentを変更する必要があります。

{ 
    "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" 
     } 
    } 
    } 
} 

設定{オブジェクト}

のuserAgentときにウェブページを要求するリソースユーザエージェントがサーバに送信される定義。

出典:http://phantomjs.org/api/webpage/property/settings.html

あなたはより多くの例が必要な場合:

// Mac Chrome 46 
"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" 

// Windows Chrome 46 
"phantomjs.page.settings.userAgent" : "Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36" 

// Mac Firefox 42.0 
"phantomjs.page.settings.userAgent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0" 

// Windows Firefox 42.0 
"phantomjs.page.settings.userAgent" : "Mozilla/5.0 (Windows NT 6.3; rv:42.0) Gecko/20100101 Firefox/42.0" 

// PhantomJS 2.0 
"phantomjs.page.settings.userAgent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.0.0 Safari/538.1" 
+0

私は "phantomjs.page.settings.userAgent" を追加しようとしました:「Mozillaの/ 5.0(Macintosh版、インテルのMac OS X 10/10_5)AppleWebKit/537.36(GeckoのようなKHTML)Chrome/46.0.2490.80 Safari/537.36 "は設定ファイルにありますが、ブラウザはまだ起動しています。 –

関連する問題