Firefox上的Reactjs Cypress:错误:在浏览器中找不到url目标:空白。目标是[]
我在运行测试馆图和柏树的React应用测试时面临错误。在单位测试和E2E Chrome上运行的测试是可以的,直到在E2E Firefox上运行。
我以前从未使用过firefox,我是从
欢迎有关如何解决此问题的任何想法。谢谢大家的阅读。
版本
"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"
},
终端的完整日志:
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有一个空旷的问题“仍在等待在cypress 10.0.2中连接到firefox的问题。 Windows#22086 。
我可以在系统上确认同样的情况。
但是,我可以使用 nofollow noreferrer“> firefox夜间
/strong>
这些是Firefox(在C:/Program Files)中使用的途径,
我都具有“稳定”(
指定 - 浏览器Firefox
)和“夜间”(由指定 - - - 浏览器Firefox:Nightly
),但我看不出为什么“稳定”没有启动。它似乎以“每晚”的方式安装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
These are the paths used for Firefox (under C:/Program Files)
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"