hurt-tomatoH
Apify & Crawleeβ€’2y agoβ€’
8 replies
hurt-tomato

Taking a screenshot with Selenium/Python

Hello team! I'm just starting out and would appreciate some help here. I'm running into an error that I don't have enough tools to understand unless I see the page that's being scraped visually, so I wanted to use the save_screenshot feature with Selenium. It seems like the code does take the screenshot, and according to my understanding from guides I read, it should be saved to the KeyValueStoarge, but after I run the code, I can't find it in the storage. What am I missing?

This is the piece of code I'm running on an Actor in the Apify platform:
def screenshot_error(driver, store_id):
    random_number = random.randint(1000000,9999999)
    key = f'ERROR-LOGIN-{random_number}'
    driver.save_screenshot(f"{key}.png")
    screenshot_link = f'https://api.apify.com/v2/key-value-stores/{store_id}/records/{key}'
    Actor.log.info(f"screenshot path: {screenshot_link}")

Thanks in advance πŸ™‚
Was this page helpful?