node.js - A few Webdriver IO Mocha Chai questions -


i new using webdriver-io mocha , chai. first of here script:

var homepage = 'http://www.mypage.com'; var expect = require("chai").expect; var headertext = 'h1.browse-header-title'; var currentheadertext; var links = ['furniture','fine art','jewelry & watches','fashion'];  describe('test suite 1', function(){      before(function(){        console.log('running navigation h1 tag suite');     });      aftereach(function(){         browser.close();         // method use?     });      it('should click furniture , page header should match', function(done){        browser.url(homepage).click('a[data-tn="global-nav-item-link-furniture"]');         currentheadertext = browser.gettext(headertext);         expect(currentheadertext).to.equal(links[0]);         console.log('h1 tag '+currentheadertext+'');     });     it('should click fine art , page header should match', function(done){         browser.url(homepage).click('a[data-tn="global-nav-item-link-fine-art"]');         currentheadertext = browser.gettext(headertext);         expect(currentheadertext).to.equal(links[1]);         console.log('h1 tag '+currentheadertext+'');      });     it('should click jewelry & watches , page header should match', function(done){         browser.url(homepage).click('a[data-tn="global-nav-item-link-jewelry-&-watches"]');         currentheadertext = browser.gettext(headertext);         expect(currentheadertext).to.equal(links[2]);         console.log('h1 tag '+currentheadertext+'');     });     it('should click fashion , page header should match', function(done){         browser.url(homepage).click('a[data-tn="global-nav-item-link-fashion"]');         currentheadertext = browser.gettext(headertext);         expect(currentheadertext).to.equal(links[3]);         console.log('h1 tag '+currentheadertext+'');     });  }); 

my first question is, there better place store variables , proper method call them?

when running aftereach browser.close() function, best way reset browser session, tried browser.reset() when calling second test didn't seem work properly. there better way mocha , chai close browser, reset session , open browser , go home page?

these requirements given:

1) test must written in mocha assertions using chai. framework used drive tests must webdriverio – no native selenium commands.

2) test should written in way utilizes page object pattern

3) variables used in other tests (such user email/password) should stored separately test file.

for storing variables outside of code, there several ways.

  1. you leverage wdio.conf.js , start adding customconfig object this , use them in code _page.navigate(browser.options.customconfig.baseurl); this
  2. or keep in separate .json file, use nconf bring test code
  3. or import data.json import testdata './testdata.json' , use them directly

as far browser.close(), requirement, if workflow, series of user actions, keep them in 1 file run them on 1 browser session. if these unrelated tests, separate specs , let wdio/mocha handle parallel execution , browser sessions you.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -