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

Support browserless.io: #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

itayadler
Copy link

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.

None yet

1 participant