Screenshot¶
Capture screenshots of the current page.
screenshot(filepath="screenshot.png")¶
Takes a screenshot of the page and saves it to a file. Returns the file path.
Debugging with Screenshots¶
from cdriv import CDriv
with CDriv() as driver:
driver.new_session()
try:
driver.navigate("https://site.com")
driver.wait_for_element("#error", timeout=5)
print("Error element found!")
except:
driver.screenshot("error.png")
print("Screenshot saved as error.png")
screenshot_as_base64()¶
Returns the screenshot as a base64 string (without saving to a file).