2017-03-23 133 views
1

什麼是最簡單的文件夾結構,我可以使用Nightwatchjs?它將在本地使用並用於持續集成。目前我甚至無法使演示工作。我有六個錯誤:Nightwatchjs文件夾結構

module.js:469:15 
module.js:417:25 
bootstrap_node.js:604.10 
bootstrap_node.js:394:7 
bootstrap_node.js:149:9 
bootstrap_node.js:509:3. 

我意識到這是一個初學者問題。我已經使用了Telerik和TestComplete幾年了,現在我們想要正確地配置CI,所以Selenium是最好的選擇。我對JavaScript感到滿意,但對文件路徑有點不好。

+0

請張貼配置文件(Nightwatch.js文件) –

回答

0

什麼是最簡單的文件夾結構,我可以使用Nightwatchjs?

最簡單的NightwatchJS文件夾結構爲:

  • 有2個文件(配置文件和文件,其中包含你測試):

    • nightwatch.json

    • app.js(您可以根據需要重新命名)

1)nightwatch.json

{ 
    "src_folders": [ 
     "app.js" 
    ], 
    "live_output": false, 
    "tests_output": "test/tests_output/", 
    "detailed_output": true, 
    "selenium": { 
     "start_process": false, 
     "host": "hub.browserstack.com", 
     "port": 80 
    }, 
    "test_workers": { 
     "enabled": false, 
     "workers": "auto" 
    }, 
    "test_settings": { 
     "chrome": { 
      "selenium_port": 80, 
      "selenium_host": "hub.browserstack.com", 
      "silent": true, 
      "desiredCapabilities": { 
       "os": "Windows", 
       "os_version": "10", 
       "browserName": "chrome", 
       "resolution": "1024x768", 
       "javascriptEnabled": true, 
       "acceptSslCerts": true, 
       "browserstack.video": "true", 
       "browserstack.debug": "true", 
       "browserstack.user": "<yourUsername>", 
       "browserstack.key": "<yourPassword>" 
      } 
     } 
    } 
} 

2)app.js

module.exports = { 
    'Does-stackoverflow-works': function (browser) { 
     browser 
      .url("http://stackoverflow.com/questions") 
      .waitForElementPresent('body', 2000, "Display latest Stackoverflow questions") 
      .end() 
    } 
}; 

運行
$> nightwatch --env chrome 

輸出

enter image description here

+0

謝謝!我redid我的安裝和問題消失了。問題與安裝順序有關。我可以通過更改一堆文件的路徑來修復錯誤。正確的安裝使我不必這樣做,並且我沒有失去我的任何工作。 – NightWatchMan