Skip to content

Instantly share code, notes, and snippets.

@dreygur
Last active June 6, 2022 09:14
Show Gist options
  • Select an option

  • Save dreygur/3d3ba94555eba0eceae16ac2c636b0d6 to your computer and use it in GitHub Desktop.

Select an option

Save dreygur/3d3ba94555eba0eceae16ac2c636b0d6 to your computer and use it in GitHub Desktop.
import base64
import requests
uri = "http://localhost:3333/session"
header = {
"content-type": "application/json",
}
# Creates a new session
res = requests.post(uri, json={
"capabilities": {
"alwaysMatch": {
"acceptInsecureCerts": True
}
}
}, headers=header)
# Stores Session ID
seddionId = res.json().get("value").get("sessionId")
# Browse to a URL
requests.post(f"{uri}/{seddionId}/url", json={
"url": "https://www.google.com",
}, headers=header)
# Take a screenshot
res = requests.get(f"{uri}/{seddionId}/screenshot", headers=header)
image = res.json().get("value")
# Saves the image to a screenshot.png file
with open("screenshot.png", "wb") as fh:
fh.write(base64.b64decode(image.encode("ASCII")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment