longvh211 / Chromium-Automation-with-CDP-for-VBA

A method to directly automate Chromium-based web browsers, such as Chrome, Edge, and Firefox, using VBA for Office applications by following the Chrome DevTools Protocol framework.
MIT License
44 stars 5 forks source link

Failed to invoke method "Target.getTargetInfo" #31

Closed maxwellem closed 3 weeks ago

maxwellem commented 1 month ago

Greetings, first want to say thank you for all of your work in this project; I've learned so much. I will say I've had no issues so far with my home lab machine; but run into this error while using the company machine (intended production use). This may be a system limitation / config that is blocking this.

16:49:58 | BRID706 | cleanUpSessions completed and previous CdpSessionID removed 16:49:58 | BRID706 | setCrashStateNormal completed 16:49:59 | BRID706 | CDPCore initialized successfully 16:50:00 | BRID706 | Now looking for the browser window 16:50:00 | BRID706 | Now attaching CDP pipes to the browser session 16:50:00 | BRID706 | Successfully attached to Session ID FE04E0A54D47C331268087B6E55B0BDB 16:50:00 | BRID706 | InvokeMethod Error: [-32001] Session with given id not found. 16:50:00 | BRID706 | Failed to invoke method "Target.getTargetInfo"

At some point after attaching to the Session, the browser returns a JSON message that says "session with given ID not found". once this parses it sends it to the error handler proc stops. I believe its supposed to show a new serial string with the targetID, but it fails somewhere around here. I can't pinpoint it.

Curious if you know of a particular (system?) configuration that's known to cause this error. Target Error

longvh211 commented 1 month ago

Hi maxwell! This usually happens when the browser does something to the original tab that is open, such as removing it and replacing it with another tab. Try to:

maxwellem commented 1 month ago

Thanks for the pointers, long! Browser (Edge/Chrome) just open up to about:blank. I can set to open google.com on startup, but still get the target error. I wonder if the setting to disable "inspect element" has to do with it. I dont believe this is the root cause because CDP can attach to the session, just not the target tab. Is there a "for hire" service we can chat about if you're interested in looking deeper into my issue / project.

longvh211 commented 1 month ago

That's interesting. Can you post your code in full? The screenshot above has the error message box covered most of it. Also a screenshot/video of your code execution would be even better.

Krazy21000 commented 3 weeks ago

Same issue here, Edge of my company opening with about:blank before redirecting on a specific website. I can't modify this parameter. Do you have any solution please ?

longvh211 commented 3 weeks ago

Did any of the demo procedure work for you?

maxwellem commented 3 weeks ago

i did some testing and this is what i found. if your company has the developer mode set to disable; it will not work.

i was able to have an admin enable developer mode and CDP worked as intended.

longvh211 commented 3 weeks ago

I see. Thanks for the important insight maxwell!