ForbesLindesay / cabbie

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

startChromedriver won't work #15

Open joscha opened 7 years ago

joscha commented 7 years ago

I keep on getting:

Error: connect ECONNREFUSED 127.0.0.1:9515
    at doRequestWith (/Users/joscha/Development/canva/web/node_modules/sync-request/index.js:87:11)
    at doRequest (/Users/joscha/Development/canva/web/node_modules/sync-request/index.js:20:10)
    at Connection.request (/Users/joscha/Development/canva/web/node_modules/cabbie-sync/lib/connection.js:154:52)
    at createSession (/Users/joscha/Development/canva/web/node_modules/cabbie-sync/lib/driver.js:385:24)
    at Driver (/Users/joscha/Development/canva/web/node_modules/cabbie-sync/lib/driver.js:201:20)
    at createCabbieDriver (/Users/joscha/Development/canva/web/node_modules/cabbie-sync/lib/index.js:221:29)
    at Object.<anonymous> (/Users/joscha/Development/canva/web/src/pages/editor/happy-path.js:9:16)
    at Module._compile (module.js:571:32)
    at loader (/Users/joscha/Development/canva/web/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/joscha/Development/canva/web/node_modules/babel-register/lib/node.js:154:7)

After googling, this is presumably a problem with the startChromedriver method. It happens both with cabbie-sync and cabbie-async.

joscha commented 7 years ago

The code is:

import assert from 'assert';
import cabbie, { startChromedriver } from 'cabbie-sync';

// 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.browser.activeWindow.navigateTo('http://example.com');

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

it works fine with taxi-rank.

ForbesLindesay commented 7 years ago

Yes, I think the chromedriver npm package may have stopped working reliably. I'm not sure what's causing this. I think the best way to resolve this might just be to download chromedriver separately (from https://chromedriver.storage.googleapis.com/index.html?path=2.29/) and then run it in a separate terminal, manually.