2014-07-08 10 views
0

我試圖執行基本功能測試:與intern.js和browserstack工作,訪問遠程瀏覽器環境

define([ 
    'intern!object', 
    'intern/chai!assert', 
    '../Request', 
    'require' 
], function (registerSuite, assert, Request, require) { 
    var request, 
     url = 'https://github.com/theintern/intern'; 

    registerSuite({ 
     name: 'demo', 

     'submit form': function() { 
      return this.remote 
       .get(require.toUrl('./fixture.html')) 
       .findById('operation') 
        .click() 
        .type('hello, world') 
       .end() 
       .findById('submit') 
        .click() 
       .end() 
       .setFindTimeout(Infinity) 
       .findById('result') 
       .setFindTimeout(0) 
       .text() 
       .then(function (resultText) { 
        assert.ok(resultText.indexOf(
         '"hello, world" completed successfully') > -1, 
         'On form submission, operation should complete successfully'); 
       }); 
     } 
    }); 
}); 

(例如,從intern.js文檔) https://github.com/theintern/intern/wiki/Writing-Tests-with-Intern

我intern.js配置文件如下:

define({ 


proxyPort: 9000, 
    proxyUrl: 'http://localhost:9000/', 
    capabilities: { 
     'selenium-version': '2.41.0' 
    }, 
    environments: [ 
     { browserName: 'chrome'} 
    ], 
    maxConcurrency: 3, 
    tunnel: "BrowserStackTunnel", 
    webdriver: { 
     host: 'http://hub.browserstack.com/wd/hub', 
     username: 'XXXXX', 
     accessKey: 'XXXXX' 
    }, 
    useSauceConnect: false, 
    loader: { 
     packages: [ 
     { 
      name: "dojo", 
      location: 'vendor/dojo' 
     } 
     ] 
    }, 
    suites: [ "tests/test" ], 
    excludeInstrumentation: /^(?:tests|node_modules)\// 
}); 

當我運行我的測試,似乎正在連接與browserstack做,但我的T美國東部時間持續出現故障:

-> ./node_modules/.bin/intern-runner config=tests/intern 
Listening on 0.0.0.0:9000 
Starting tunnel... 
BrowserStackLocal v2.2 
Ready 
Initialised chrome 35.0.1916.114 on XP 
Test main - index - test FAILED on chrome 35.0.1916.114 on XP: 
TypeError: Cannot read property 'get' of null 
    at Test.registerSuite.test <tests/test.js:11:17> 
    at Test.run <__intern/lib/Test.js:154:19> 
    at <__intern/lib/Suite.js:212:13> 
    at signalListener <__intern/node_modules/dojo/Deferred.js:37:21> 
    at Promise.then.promise.then <__intern/node_modules/dojo/Deferred.js:258:5> 
    at <__intern/lib/Suite.js:211:46> 

我假設的webdriver沒有加載,怎麼可以訪問我的功能測試中遠程瀏覽器環境?

回答

1

只有功能測試與WebDriver客戶端交互並具有remote屬性。在您的配置中,將您的測試套件包含在functionalSuites陣列中,而不是suites

請注意,webdriver屬性不再使用,所以如果你想在配置文件中指定你的用戶名和訪問密鑰,你應該使用tunnelOptions來代替。

tunnelOptions: { 
    username: <username>, 
    accessKey: <accessKey> 
} 

隧道知道默認使用的正確主機名,所以你不需要提供。

+0

感謝您的回覆。我使用了tunnelOptions屬性和functionalSuites而不是套件,但它沒有解決我的問題。我仍然無法發送任何命令給browserstack或saucelabs。瀏覽器打開一個白頁。 – cleau

相關問題