Home > front end >  Reactjs cypress on firefox: Error: Could not find url target in browser about:blank. Targets were []
Reactjs cypress on firefox: Error: Could not find url target in browser about:blank. Targets were []

Time:06-15

I'm facing an error while running tests of an react app with testing-library and cypress. Tests running on unit test and e2e chrome is fine till it running on e2e firefox.

I haven't used firefox before, i was installed firefox from here to run the test on demand, but it doesn't seem to work. I've tried searching the internet for errors but couldn't find any similar articles.

Any ideas on how to solve this are welcome. Thank you all for reading.

Versions

"react": "^18.1.0",
"cypress": "^10.0.2",
"@cypress/react": "^5.12.5",
"@cypress/webpack-dev-server": "^1.8.4",

Config packages.json

"scripts": {
  ...
  "test:all": "react-scripts test --transformIgnorePatterns \"node_modules/(?!@mui)/\" --watchAll=false && npm run test:e2e:all",
  "test:unit": "react-scripts test --transformIgnorePatterns \"node_modules/(?!@mui)/\"",
  "test:e2e:all": "npm run test:e2e:chrome && npm run test:e2e:firefox && npm run test:e2e:edge && npm run test:e2e:tablet",
  "test:e2e:chrome": "npx cypress run --headless --browser chrome",
  "test:e2e:firefox": "npx cypress run --headless --browser firefox",
  "test:e2e:edge": "npx cypress run --headless --browser edge",
  "test:e2e:tablet": "npx cypress run --headless --browser chrome --config viewportWidth=800"
},

Full log from terminal:

PS E:\react-todolist-recoil> yarn test:all
yarn run v1.22.4
$ react-scripts test --transformIgnorePatterns "node_modules/(?!@mui)/" --watchAll=false && npm run test:e2e:all
 PASS  src/pages/Fetch/fetch.test.tsx (6.236 s)
 PASS  src/pages/Home/home.test.tsx (15.773 s)

Test Suites: 2 passed, 2 total
Tests:       17 passed, 17 total
Snapshots:   0 total
Time:        17.798 s, estimated 18 s
Ran all test suites.

> [email protected] test:e2e:all
> npm run test:e2e:chrome && npm run test:e2e:firefox && npm run test:e2e:edge && npm run test:e2e:tablet      


> [email protected] test:e2e:chrome
> npx cypress run --headless --browser chrome



====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        10.0.2                                                                         │
  │ Browser:        Chrome 102 (headless)                                                          │
  │ Node Version:   v16.15.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          2 found (home.cy.ts, login.cy.ts)                                              │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  home.cy.ts                                                                      (1 of 2)


  HomePage tests
    √ truy cập, hiển thị các component quan trọng (1949ms)
    √ home_toolbar: tiêu đề và các button (613ms)
    √ home_toolbar: disable một số button khi không có dữ liệu (523ms)
    √ home_toolbar: flow add dữ liệu (915ms)
    √ home_toolbar: flow import dữ liệu từ file xlsx (623ms)
    √ home_toolbar: flow xóa toàn bộ dữ liệu (523ms)
    √ home_table: table row và các action button (492ms)
    √ home_table: flow đánh dấu todo là đã hoàn thành (507ms)
    √ home_table: flow cập nhật một table_row (todo) (1107ms)
    √ home_table: flow xóa một table_row (todo) (602ms)
    √ home_pagination: hiển thị dữ liệu giới hạn (1412ms)
    √ home_pagination: hiển thị dữ liệu theo trang (947ms)


  12 passing (10s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        12                                                                               │
  │ Passing:      12                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     10 seconds                                                                       │
  │ Spec Ran:     home.cy.ts                                                                       │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: E:\react-todolist-recoil\cypress\videos\home.cy.ts.mp4         (2 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  login.cy.ts                                                                     (2 of 2)


  login.cy.ts
    √ should visit (1094ms)


  1 passing (1s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     1 second                                                                         │
  │ Spec Ran:     login.cy.ts                                                                      │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: E:\react-todolist-recoil\cypress\videos\login.cy.ts.mp4        (0 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ √  home.cy.ts                               00:10       12       12        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  login.cy.ts                              00:01        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    √  All specs passed!                        00:11       13       13        -        -        -  


> [email protected] test:e2e:firefox
> npx cypress run --headless --browser firefox



====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        10.0.2                                                                         │
  │ Browser:        Firefox 101 (headless)                                                         │
  │ Node Version:   v16.15.0 (C:\Program Files\nodejs\node.exe)                                    │
  │ Specs:          2 found (home.cy.ts, login.cy.ts)                                              │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  home.cy.ts                                                                      (1 of 2)
Still waiting to connect to Firefox, retrying in 1 second (attempt 18/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 19/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 20/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 21/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 22/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 23/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 24/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 25/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 26/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 27/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 28/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 29/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 30/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 31/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 32/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 33/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 34/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 35/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 36/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 37/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 38/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 39/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 40/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 41/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 42/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 43/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 44/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 45/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 46/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 47/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 48/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 49/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 50/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 51/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 52/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 53/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 54/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 55/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 56/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 57/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 58/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 59/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 60/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 61/62)
Still waiting to connect to Firefox, retrying in 1 second (attempt 62/62)
Cypress failed to make a connection to Firefox.

This usually indicates there was a problem opening the Firefox browser.

Error: Could not find url target in browser about:blank. Targets were []
    at C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\browser-cri-client.js:90:27
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at retry (C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\browser-cri-client.js:39:20)
    at setupRemote (C:\Users\IVS\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\packages\server\lib\browsers\firefox-util.js:109:27)

error Command failed with exit code 1.

CodePudding user response:

There's an open issue here "Still waiting to connect to Firefox" issue in Cypress 10.0.2 on Windows #22086.

I can confirm the same occurs on my system.

But, I can use Firefox nightly

script

"test:e2e:firefox": "npx cypress run --headless --browser firefox:nightly",

These are the paths used for Firefox (under C:/Program Files)

stable: getFirefoxPaths('Mozilla Firefox'),  
dev: getFirefoxPaths('Firefox Developer Edition'),
nightly: getFirefoxPaths('Firefox Nightly'),

I have both "stable" (specified by --browser firefox) and "nightly" (specified by --browser firefox:nightly) but I can't see why "stable" isn't firing up. It seems to be installed the same way a "nightly"

  • Related