ForbesLindesay / cabbie

WebDriver for the masses
https://cabbiejs.org/
MIT License
70 stars 11 forks source link

getting an error #19

Closed lkkushan closed 6 years ago

lkkushan commented 6 years ago

My code is -

var assert = require('C:/slimerTest/node_modules/assert');
var {startChromedriver} = require('C:/slimerTest/node_modules/cabbie-sync');
var cabbie = require ('C:/slimerTest/node_modules/cabbie');

// Start the chromedriver server, this provides a local selenium server
// You must install chromedriver to use this.
startChromedriver();

// connect to chromedriver, adding {debug: true} makes cabbie log each method call.
const driver = cabbie('chromedriver', {debug: true});

try {
  // navigate to a url in the currently active window
  driver.activeWindow.navigateTo('http://example.com');

  // get an element, and check that its text equals some expected value
  assert.equal(
    driver.activeWindow.getElement('h1').getText(),
    'Example Domain',
  );
} finally {
  // whether tests pass or fail, dispose of the driver
  //driver.dispose();
}

But im getting an error when i run through node command const driver = cabbie('chromedriver', {debug: true}); ^

TypeError: cabbie is not a function

why is this?

ForbesLindesay commented 6 years ago

cabbie and cabbie-sync are ES Modules, so you need to use the default export. Instead of:

var assert = require('C:/slimerTest/node_modules/assert');
var {startChromedriver} = require('C:/slimerTest/node_modules/cabbie-sync');
var cabbie = require ('C:/slimerTest/node_modules/cabbie');

Try doing:

var assert = require('assert');
var {startChromedriver} = require('cabbie-sync');
var cabbie = require ('cabbie-sync').default;