cyrus-and / chrome-har-capturer

Capture HAR files from a Chrome instance
MIT License
535 stars 90 forks source link

Error: Cannot inject JavaScript #92

Closed ICYPOLE closed 3 years ago

ICYPOLE commented 3 years ago

OS: CentOS Linux release 7.5.1804 (Core) Google Chrome: 72.0.3626.81 Node.js: v10.15.1 npm: v6.4.1

> npm list
├─┬ chrome-har-capturer@0.13.9
│ ├─┬ chalk@1.1.3
│ │ ├── ansi-styles@2.2.1
│ │ ├── escape-string-regexp@1.0.5
│ │ ├─┬ has-ansi@2.0.0
│ │ │ └── ansi-regex@2.1.1
│ │ ├─┬ strip-ansi@3.0.1
│ │ │ └── ansi-regex@2.1.1 deduped
│ │ └── supports-color@2.0.0
│ ├─┬ chrome-remote-interface@0.25.7
│ │ ├── commander@2.11.0 extraneous
│ │ └─┬ ws@3.3.3
│ │   ├── async-limiter@1.0.1
│ │   ├── safe-buffer@5.1.2
│ │   └── ultron@1.1.1
│ └── commander@2.20.3
└── colors@1.4.0

Steps to reproduce the problems

  1. Start Chrome
    google-chrome --remote-debugging-port=9222 --headless
  2. Run chrome-har-capturer
    chrome-har-capturer -o test.har "http://www.google.com"

Then error occurs:

Cannot connect to Chrome
Error: Cannot inject JavaScript: {
    "result": {
        "type": "object",
        "subtype": "error",
        "className": "ReferenceError",
        "description": "ReferenceError: chrome is not defined\n    at <anonymous>:1:1",
        "objectId": "{\"injectedScriptId\":2,\"id\":1}"
    },
    "exceptionDetails": {
        "exceptionId": 2,
        "text": "Uncaught",
        "lineNumber": 0,
        "columnNumber": 0,
        "scriptId": "14",
        "exception": {
            "type": "object",
            "subtype": "error",
            "className": "ReferenceError",
            "description": "ReferenceError: chrome is not defined\n    at <anonymous>:1:1",
            "objectId": "{\"injectedScriptId\":2,\"id\":2}"
        }
    }
}
cyrus-and commented 3 years ago

I think despite your npm list you're using a very old version of chrome-har-capturer, that thing is no more used since 2017.