We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d046e88 + 7facb89 commit e34c6b8Copy full SHA for e34c6b8
botcity/web/bot.py
@@ -312,14 +312,18 @@ def get_screen_image(self, region=None):
312
if not region:
313
region = (0, 0, 0, 0)
314
315
- data = self._driver.get_screenshot_as_base64()
316
- image_data = base64.b64decode(data)
317
- img = Image.open(io.BytesIO(image_data))
318
-
319
x = region[0]
320
y = region[1]
321
width = region[2] or self._get_page_size()[0]
322
height = region[3] or self._get_page_size()[1]
+
+ try:
+ data = self._driver.get_screenshot_as_base64()
+ image_data = base64.b64decode(data)
323
+ img = Image.open(io.BytesIO(image_data))
324
+ except: # noqa: E722
325
+ img = Image.new("RGB", (width, height))
326
327
img = img.crop((x, y, x + width, y + height))
328
return img
329
0 commit comments