'Arsenic async API : session.get_screenshot() to capture image in particular location
I have been trying to take screenshot of captcha based on ID from URL https://elegalix.allahabadhighcourt.in/elegalix/WebStartCaseSearch.do in arsenic async web driver.
async with get_session(services.Chromedriver(), self.browser) as sesssion:
await session.get("https://elegalix.allahabadhighcourt.in/elegalix/WebStartCaseSearch.do")
#Below gives <_io.BytesIO object at 0x7f6625119f68>. How to retrieve captcha image from this object
captcha_image = session.get_screenshot()
But as per API documentation of Arsenic https://arsenic.readthedocs.io/en/latest/reference/session.html,
get_screenshot() : Coroutine to take a screenshot of the top-level browsing context’s viewport. Return type: io.BytesIO
we can only take entire page of screenshot, I would like to know any way to take particular image element ID and store it as base64 as we do it in Selenium below.
captcha_image = driver.find_element_by_id(
'captcha_image'
).screenshot_as_base64
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
