Skip to content

Support browserless.io:#40

Open
itayadler wants to merge 3 commits intoandrewvy:masterfrom
itayadler:master
Open

Support browserless.io:#40
itayadler wants to merge 3 commits intoandrewvy:masterfrom
itayadler:master

Conversation

@itayadler
Copy link
Copy Markdown

Context

browserless.io only supports connecting to the browser websocket, and not to a target (page) websocket, so in order to use it, skip straight to PageSession.start_link:

{:ok, page} =
  ChromeRemoteInterface.PageSession.start_link(
    "wss://chrome.browserless.io/?token=your_token"
  )
{:ok, targetResult} =
  ChromeRemoteInterface.RPC.Target.createTarget(page, %{
    url: "https://google.com",
    width: 1280,
    height: 800
  })

targetId = targetResult["result"]["targetId"]

{:ok, sessionResult} =
  ChromeRemoteInterface.RPC.Target.attachToTarget(page, %{targetId: targetId, flatten: true})

sessionId = sessionResult["result"]["sessionId"]
{:ok, screenshot1} =
  ChromeRemoteInterface.RPC.Page.captureScreenshot(page, %{format: "png"},
    session_id: sessionId
  )

Notice that we need to pass the session_id to each command, otherwise without the session_id the command will run on the browser context, in other words it will fail for all commands that are related to the page.

  • Allow to pass session_id for ChromeRemoteInterface.RPC
  • Handle ssl_closed in websocket
  • Update tot json

- Allow to pass session_id for ChromeRemoteInterface.RPC
- Handle ssl_closed in websocket
- Update tot json
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

Successfully merging this pull request may close these issues.

1 participant