Last active
November 7, 2020 20:21
-
-
Save lgsantiago/9088458a43dd2d1fcee572ab1bbce93c to your computer and use it in GitHub Desktop.
Wodify automation: screenshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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