Comments for Connect To Browser

Topic for comments about Browser library keyword Connect To Browser

Hello,

I’m using Robot Framework with Robocorp but I can’t get this Playwright keyword to work. For comparison, I’ve been able to use Selenium’s Attach Chrome Browser keyword to attach to an existing Chrome browser.

As described in the above link, I start chome.exe with -remote-debugging-port=9222 and then simply passing the int 9222 to the keyword allows me to start using that preexisting Chrome browser.

On the other hand, trying with Playwright’s use connect_to_browser(wsEndpoint) simply hangs the program. For example, wsEndpoint = "ws://127.0.0.1:9222/devtools/browser/7d35a0b9-b634-4883-9b04-b44e3547d098". Is this format correct? When I try other forms such as wsEndpoint = "http://127.0.0.1:9222" I get TypeError: browserType.connect: Cannot read properties of undefined (reading ‘startsWith’)`.

To help debug, I tracked down the definition of connect_to_browser(), broke it up into a few more lines, and added a bit of logging, which shows that the program is hanging at line 315 response = stub.ConnectToBrowser(conn_brow):

I’m seeing in the description that this keyword allows you to “connect to a playwright Browser”. Does this mean that it can’t connect to a browser created from the commandline as shown in the above link?

Am I using the right keyword? Is this even possible with the Playwright library?

Thanks

PS. I’ve also tried with Edge without any luck.

@mkorpela Would it be possible to get an example of how this can be used?

I’ve also tried first launching a context with playwright and then connecting to that one but no luck. I was following this example: [Question] Trying to connect to existing playwright session via Chromium CDP · Issue #11442 · microsoft/playwright · GitHub

I would really prefer not to go back to selenium, I would much rather keep working with playwright.

Can I use this to Selenoid instance browser?

I get an error when I use " Connect To Browser" to connect to open android device with chrome browser on lambda test. Any help will be appreciated!
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.RESOURCE_EXHAUSTED
details = “Error: browserType.connect: Malformed endpoint. Did you use BrowserType.launchServer method?”
debug_error_string = “UNKNOWN:Error received from peer {grpc_message:“Error: browserType.connect: Malformed endpoint. Did you use BrowserType.launchServer method?”, grpc_status:8, created_time:“2023-11-15T18:49:35.748024+01:00”}”