index.js 827 B

123456789101112131415161718192021222324252627282930313233343536373839
  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('start chromedriver');
  10. const service = chromedriver.start(args);
  11. console.log('after start')
  12. const options = {
  13. port,
  14. path: '/',
  15. desiredCapabilities: {
  16. browserName: 'chrome',
  17. chromeOptions: {
  18. args: ['--headless', '--disable-gpu'],
  19. }
  20. },
  21. };
  22. const client = webdriverio
  23. .remote(options)
  24. .init()
  25. .on('error', (e) => console.error(e))
  26. .once('end', () => {
  27. process.nextTick(function () {
  28. chromedriver.stop();
  29. });
  30. })
  31. .url('https://www.google.com')
  32. .getTitle().then(function (title) {
  33. console.log('Title was: ' + title);
  34. }).catch(console.log)
  35. .end();