javascript - driver.get multiple urls causes false test failure -


i'm getting started on system contain growing collection of single page apps , i'm looking how organize ui tests scale sanely. i'd write test module per page exercise verify i'm having trouble invoking driver.get() in succession.

specs/index.js

var webdriver = require('selenium-webdriver'); var test = require('selenium-webdriver/testing'); var expect = require('chai').expect; var server = new require('selenium-webdriver/remote').seleniumserver(path, {port: 4444}); var specs = [     require('./google'), require('./bing') ];  //...  var driver = new webdriver.builder()          .usingserver(server.address())          .withcapabilities(webdriver.capabilities.firefox())          .build();  test.describe('while learning webdriverjs', function() {     test.after(function() {         driver.quit();     });      specs.foreach(function(spec) {         spec.run(driver, webdriver, test);     }); }); 

specs/bing.js

var expect = require('chai').expect;  function run(browser, webdriver, test) {     test.describe('a trip bing', function() {         browser.get('http://www.bing.com');          test.it('does not fail', function() {             browser.gettitle().then(function(title) {                expect(title).to.equal('bing');             });         });     }); }  module.exports = { run: run }; 

specs/google.js

var expect = require('chai').expect;  function run(browser, webdriver, test) {     test.describe('a trip google', function() {         browser.get('http://www.google.com');          test.it('does not fail', function() {             browser.gettitle().then(function(title) {                 expect(title).to.equal('google');             });         });     }); }  module.exports = { run: run }; 

now running either google.js or bing.js alone runs fine, running 2 in succession returns:

while learning webdriverjs     trip bing       1) not fail     trip google       ✓ not fail   1 passing (12s) 1 failing  1) while learning webdriverjs trip bing not fail me:    + expected - actual    +"bing"   -"google"    @ <anonymous> ==== async task ==== webdriver.gettitle()   @ webdriver.webdriver.schedule (/.../node_modules/selenium-    webdriver/lib/webdriver/webdriver.js:267:15)   @ webdriver.webdriver.gettitle (/.../node_modules/selenium-webdriver/lib/webdriver/webdriver.js:640:15)   @ /.../projects/learn-webdriver/specs/bing.js:9:11   @ webdriver.promise.controlflow.runinnewframe_ (/.../node_modules/selenium-webdriver/lib/webdriver/promise.js:1445:20)   @ webdriver.promise.controlflow.runeventloop_ (/.../node_modules/selenium-webdriver/lib/webdriver/promise.js:1310:8)   @ wrapper [as _ontimeout] (timers.js:252:14)   @ timer.listontimeout [as ontimeout] (timers.js:110:15) ==== async task ====   @ context.<anonymous> (/.../node_modules/selenium-webdriver/testing/index.js:119:12)   @ test.runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:194:15)   @ runner.runtest (/usr/local/lib/node_modules/mocha/lib/runner.js:372:10)   @ /usr/local/lib/node_modules/mocha/lib/runner.js:448:12   @ next (/usr/local/lib/node_modules/mocha/lib/runner.js:297:14)   @ /usr/local/lib/node_modules/mocha/lib/runner.js:307:7   @ next (/usr/local/lib/node_modules/mocha/lib/runner.js:245:23)   @ object._onimmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:274:5)   @ processimmediate [as _immediatecallback] (timers.js:330:15) 

not entirely sure i'm doing wrong, i'm sure driver.get() moving faster specs. i've noticed using done() complete async test isn't available in selenium-webdriver/testing (i got "undefined not function" when tried).

i've tried not using selenium wrapped mocha globals strange results - on win 7 enterprise, tests pass, browser fired , fails afterwards throws exception; on ubuntu 12.04 machine, tests pass , no browser instance ever loads.

i'm sure haven't exhausted possible ways organize these tests they'd run properly, can't see them atm.

it looks you're running tests in parallel, yet you're passing through same instance of driver each they'll sharing browser window.

i'm not sure you're using webdriverjs testing stuff correctly either. i've not used myself if there's test.describe(...) i'd expect there test.it(...).

take @ one of test files in web driver how write tests.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -