index.js 808 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const webdriverio = require('webdriverio');
  2. const chromedriver = require('chromedriver');
  3. // todo: stop works only with 9515
  4. const port = 9515;
  5. const args = [
  6. // '--url-base=/wd/hub',
  7. `--port=${port}`
  8. ];
  9. console.log(args);
  10. console.log('start chromedriver');
  11. chromedriver.start(args);
  12. console.log('after start')
  13. const options = {
  14. port,
  15. path: '/',
  16. desiredCapabilities: {
  17. port,
  18. browserName: 'chrome',
  19. },
  20. };
  21. webdriverio
  22. .remote(options)
  23. .init()
  24. .on('error', (e) => console.error(e))
  25. .once('end', () => {
  26. console.log('end');
  27. process.nextTick(function () {
  28. console.log('stopping');
  29. chromedriver.stop();
  30. });
  31. })
  32. .url('https://www.google.com')
  33. .getTitle().then(function (title) {
  34. console.log('Title was: ' + title);
  35. }).catch(console.log)
  36. .end();