OnetapInc / chromy

Chromy is a library for operating headless chrome. 🍺🍺🍺
MIT License
606 stars 41 forks source link

Open Chrome with user logged in. #106

Open alucardu opened 6 years ago

alucardu commented 6 years ago

Is it possible to open a Chrome browser with Chromy with a user logged in with his google account in the browser?

dotneet commented 6 years ago

userDataDir option can be used to open a browser with specific browser profile. https://github.com/OnetapInc/chromy#options

alucardu commented 6 years ago

I'm having some difficulty implementing this in my application. I'm running BackstopJS for my test scenarios with Chrome is the engine so I can use Chromy.

BackstopJS has made userDataDir available in their configuration but this causes a bug when running multiple scenarios. So I would like to add the userDataDir value to each scenario separately.

I have this onBefore.js script that runs on each scenario:

module.exports = function (chromy, scenario, vp) {
  require('./loadCookies')(chromy, scenario);

  // IGNORE ANY CERT WARNINGS
  chromy.ignoreCertificateErrors();

  return chromy
    .wait(150)

};

Could you perhaps give an example on how to implement the userDataDir in this set up?

//update.

Never mind, seem like adding chromy.options.userDataDir = "C:/Users/Peter/AppData/Local/Google/Chrome/User Data/Default"; to the onBeforej.js script does the trick :)