Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsEval works only with main session. #16

Open
arkanpay opened this issue Apr 25, 2024 · 0 comments
Open

jsEval works only with main session. #16

arkanpay opened this issue Apr 25, 2024 · 0 comments

Comments

@arkanpay
Copy link

I want to open two tabs in Chrome, switch between them, and execute some JavaScript code. The problem is that I can only execute JavaScript for the main session. The other session gives me an error.

Dim browser As AutomateBrowser
Dim cdpT As cdpTarget
Set browser = new_automateBrowser
browser.launch whichBrowser:=Chromium
Set cdpT = New_cdpTarget(browser.cdp)
firstURLTargetID = cdpT.createTarget(firstURL)
SecondURLTargetID = cdpT.createTarget(SecondURL)
jsCode = "console.log('hi')"
browser.jsEval (jsCode) 'This will log "hi" in chrome console (as we don't use launch, the main tab is empty)
firstURLSessionID = cdpT.attachToTarget(firstURLTargetID)
browser.switchTo firstURLSessionID
'So far everything is working normal, I can see curSession in browser object changed to firstURLSessionID
browser.jsEval (jsCode) 'This will return Error: [-32001] Session with given id not found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant