3

I'm trying my hands at intern.js to automate my UI test. And I want to some test to run on separate browser ,i.e

  1. open new browser run test
  2. run test
  3. close browser

and so on

but I'm unable to figure out when or where does intern script open browser , and how can i open new browser window by running selenium script.

Heres my code:

intern.js

   define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
capabilities: {
    'selenium_version': '2.48.2',
}, 
environments: [
    { browserName: 'chrome', version: '48', platform: [ 'WINDOWS' ] },
],
maxConcurrency: 3,

tunnel: 'NullTunnel',
 reporters: [
     {id:'Runner'},
        {id:'Console'},
    ], 
   Loaders: {
    'host-node': 'dojo/dojo',
    'host-browser': 'node_modules/dojo/dojo.js'
},
loaderOptions: {
    packages: [ { name: 'intern-tutorial', location: '.' } ]
},
functionalSuites: [
'Automation/test/login/loginpagetest'
],
defaultTimeout: 610000,
excludeInstrumentation: /^(?:tests|node_modules)\//
 });

loginpagetest.js

 // in tests/functional/index.js
define([
'intern!object',
'intern/chai!assert',
'Automation/ConfigFiles/dataurl',
'Automation/pages/login/loginpage',
'intern/dojo/node!fs',
'intern/dojo/node!leadfoot/helpers/pollUntil'
], function (registerSuite, assert,dataurl, LoginPage,fs,pollUntil) {
registerSuite(function () {
    var loginPage;
    var values;
    return {
        // on setup, we create an IndexPage instance
        // that we will use for all the tests
        setup: function () {
            var data = fs.readFileSync(loginpage, 'utf8');
            json=JSON.parse(data);
            console.log('####################Setting Up Login Page Test#######################')
            values = json.values;
           return this.remote
                .get(require.toUrl(json.locator.URL)).setFindTimeout(6000000000).sleep(5000)
        },

        'successful login': function () {
            console.log('####################Login Success Test#######################')
            loginPage = new LoginPage(this.remote,json.locator);
             loginPage
                .login(values.unamevalue,values.pwdvalue)
            var loginSuccess = loginPage.isLoginSuccess();
            assert.isTrue(loginSuccess, 'Login Failed');
         },
        'failed login': function () {
          // test faild login
        },
      };
    });
 });

loginpage.js

  define(function (require) {

   function LoginPage(remote,locator) {
    this.remote = remote;
    this.locator = locator;
}

LoginPage.prototype = {
    constructor: LoginPage,

    login: function (username, password) {
        return this.remote
            .findById(this.locator.uname)
            .then(function () {
                return true;
            })
            .type(username).click() // for QABOX //
            .end()
            .findById(this.locator.nextbtn).sleep(3000)
            .click().end()
            .findById(this.locator.pwd).sleep(3000)
            .type(password).click()
            .end()
            .findById(this.locator.login).click()
            .end()
    },
    isLoginSuccess:function() {
        return this.remote.findById('dashboard');
    }

    };

  return LoginPage;
 });

In the loginpage test, I want to run successfull login in the seperate browser and close browser when the test is complete and failed login in another browser and close browser when the test is complete/ How can I achieve that? Can any one help??

  • Did you ever figure out what you were trying to do? – Chris Kenst Jun 30 '18 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.