Skip to content

jsEval works only with main session. #16

@arkanpay

Description

@arkanpay

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions