Closed passbe closed 1 year ago
Playwright is not supported on browserless/chrome. (ref: https://github.com/browserless/chrome/issues/1419 ) Probably, we can use playwright.chromium.connect_over_cdp instead of Playwright.connect_to_playwright_server.
Thank you for getting back to me so quickly. It appears I'm not able to call connect_over_cdp
without a Playwright block already established which requires specifying playwright_cli_executable_path
.
The documentation here shows it should be possible however, how do you establish a playwright instance to use?
I'm afraid that I made a bit misunderstanding.
It seems that recent browserless/chrome
uses playwright.chromium.launchServer
internally.
https://github.com/browserless/chrome/blob/7cff7da00b155034a142b5244f6fb81b6749c327/src/chrome-helper.ts#L595
So probably we can use Playwright.connect_to_browser_server
instead of connect_to_playwright_server
for connecting the browserless from playwright-ruby-client.
Could you try this?
Playwright.connect_to_browser_server('ws://browser:3000') do |browser|
page = browser.new_page
page.goto('https://github.com/YusukeIwaki')
page.screenshot(path: './YusukeIwaki.png')
end
@YusukeIwaki this does seem to be the case and the code snippet does connect. Thank you for your help on this issue. :+1:
Step To Reproduce / Observed behavior
I've spent a while trying to get to the bottom of this but have exhausted my knowledge here. I have the following docker container running (from my docker-compose.yml file):
By using the documented code snippet I run the following command:
Which throws the following error:
The communication is received by the browser docker container as it emits the following messages:
Debugging the issue further up the call stack I can see the following response from the docker container:
So it appears we are sending malformed JSON. Setting a breakpoint at web_socket_transport.rb:27 I can see the message we are sending:
Has something recently changed in the API which is causing the issue?
Expected behavior
To communicate with the websocket service correctly.
Environment
Appreciate any help.