Skip to content

Instantly share code, notes, and snippets.

@lgsantiago
Last active November 7, 2020 20:21
Show Gist options
  • Select an option

  • Save lgsantiago/9088458a43dd2d1fcee572ab1bbce93c to your computer and use it in GitHub Desktop.

Select an option

Save lgsantiago/9088458a43dd2d1fcee572ab1bbce93c to your computer and use it in GitHub Desktop.
Wodify automation: screenshot
# Capture Image
time.sleep(3)
image_file = 'screenshots/screenshot.png'
chrome_driver.save_screenshot(image_file)
# Get location of element to crop screenshot
element = chrome_driver.find_element_by_id("AthleteTheme_wtLayoutNormal_block_wtMainContent")
location = element.location
size = element.size
# Crop image
x = location['x']
y = location['y']
width = location['x']+size['width']
height = location['y']+size['height']
image = Image.open(image_file)
image = image.crop((int(x), int(y), int(width), int(height)))
image.save(image_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment