-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathusing-actions.py
36 lines (28 loc) · 979 Bytes
/
using-actions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Go to https://ctfd.io/, click on features, click on check-out demo
import base64
import requests
url = "http://localhost:3000/api/v1/sync-job"
token = "<visit-token>"
headers = {
"Authorization": f"Bearer {token}"
}
data = {
"steps": [
{
"url": "https://ctfd.io",
"actions": [
"page.click('#navbarResponsive > ul > li:nth-child(1) > a')",
# DO NOT use page.waitForNavigation(), tourist will automatically await each step's completion
"page.click('body > div.content > div.container.mb-5 > div:nth-child(2) > div > h5 > a')",
]
}
],
# You can create a video and a pdf the same way by using additional options: "RECORD" and "PDF"
"options": ["RECORD"]
}
response = requests.post(url, json=data, headers=headers).json()
if response["status"] == "success":
video_b64 = response["result"]["video"]
video = base64.b64decode(video_b64)
with open("video.webm", "wb+") as video_file:
video_file.write(video)