Working with intern.js and browserstack, access the remote browser environment

时光怂恿深爱的人放手 提交于 2019-12-12 02:18:31

问题


I'm trying to perform a basic functional test:

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');
                });
        }
    });
});

(Example from the intern.js documentation) https://github.com/theintern/intern/wiki/Writing-Tests-with-Intern

My intern.js configuration file is as followed:

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)\//
});

When I run my test, it seems that the connection is being made with browserstack, but my test keep failing:

-> ./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>

I assumed that the WebDriver is not loaded, how may I access the remote browser environment inside my functional test?


回答1:


Only functional tests interact with a WebDriver client and have a remote property. In your config, include your test suite in the functionalSuites array, not suites.

Note that the webdriver property is no longer used, so if you want to specify your username and access key in the config file you should use tunnelOptions instead.

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

The tunnel knows the proper hostname to use by default, so you don't need to provide that.



来源:https://stackoverflow.com/questions/24629522/working-with-intern-js-and-browserstack-access-the-remote-browser-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!