aliustaoglu / selenium-mocha-boilerplate

Minimal boilerplate for testing a web app with Selenium and Mocha
8 stars 5 forks source link

iam getting error when i run the test:e2e command with the `e2e/tests.js` demo #4

Open leodesigndev opened 3 years ago

leodesigndev commented 3 years ago

steps to reproduce the issue

1- clone the repo 2- install dependencies $yarn 3- run the app $yarn start // output --> Example app listening on port 3003! // i can open browser at http://localhost:3003 and see the login page 4- open a new console window and run $yarn test:e2e // output end with error and demo test (...e2e/tests.js) fails
// console output bellow

$ mocha --timeout 20000 e2e/tests.js --reporter mochawesome

  End to End Test Suite
Before everything login to the page

DevTools listening on ws://127.0.0.1:58604/devtools/browser/46d375b3-e26c-4ccf-80cb-3e143b9f817c
    1) "before all" hook for "can read welcome message"

  0 passing (20s)
  1 failing

  1) End to End Test Suite
       "before all" hook for "can read welcome message":
     Error: Timeout of 20000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\react\react-selenium\e2e\tests.js)
      at listOnTimeout (internal/timers.js:549:17)
      at processTimers (internal/timers.js:492:7)

[mochawesome] Report JSON saved to C:\react\react-selenium\mochawesome-report\mochawesome.json

[mochawesome] Report HTML saved to C:\react\react-selenium\mochawesome-report\mochawesome.html

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
leodesigndev commented 3 years ago

i used $npm this time arround instead of $yarn and i ran the steps above , iam getting more output in the console about the possible error

> mocha --timeout 20000 e2e/tests.js --reporter mochawesome

  End to End Test Suite
Before everything login to the page

DevTools listening on ws://127.0.0.1:60438/devtools/browser/828db0a8-0aaa-4046-900c-74bb1e47f3bd
(node:16900) UnhandledPromiseRejectionWarning: SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 83
    at Object.throwDecodedError (C:\react\react-selenium\node_modules\selenium-webdriver\lib\error.js:550:15)
    at parseHttpResponse (C:\react\react-selenium\node_modules\selenium-webdriver\lib\http.js:565:13)
    at Executor.execute (C:\react\react-selenium\node_modules\selenium-webdriver\lib\http.js:491:26)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:16900) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16900) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:16900) UnhandledPromiseRejectionWarning: SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 83
    at Object.throwDecodedError (C:\react\react-selenium\node_modules\selenium-webdriver\lib\error.js:550:15)
    at parseHttpResponse (C:\react\react-selenium\node_modules\selenium-webdriver\lib\http.js:565:13)
    at Executor.execute (C:\react\react-selenium\node_modules\selenium-webdriver\lib\http.js:491:26)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:16900) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
    1) "before all" hook for "can read welcome message"

  0 passing (20s)
  1 failing

  1) End to End Test Suite
       "before all" hook for "can read welcome message":
     Error: Timeout of 20000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\react\react-selenium\e2e\tests.js)
      at listOnTimeout (internal/timers.js:549:17)
      at processTimers (internal/timers.js:492:7)

[mochawesome] Report JSON saved to C:\react\react-selenium\mochawesome-report\mochawesome.json

[mochawesome] Report HTML saved to C:\react\react-selenium\mochawesome-report\mochawesome.html

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! selenium-mocha-boilerplate@1.0.0 test:e2e: `mocha --timeout 20000 e2e/tests.js --reporter mochawesome`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the selenium-mocha-boilerplate@1.0.0 test:e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\royle\AppData\Roaming\npm-cache\_logs\2021-04-10T04_41_33_677Z-debug.log
leodesigndev commented 3 years ago

i got it working! by installing the latest chromedriver (as of now ^89.0.0 ) steps: 1- delete node_modules 2- delete package-lock.json 3- in package.json remove "chromedriver": "^83.0.0", under devDependencies 4- $npm install -D chromedriver // result -> getting the latest chromedriver (this fix the issue above) 5- $npm update // result -> re-install the remaining dependencies 6- $npm run start 7- on a new console tab, $npm run test:e2e // restult -> success

image