Created
December 6, 2019 18:44
-
-
Save bbchriscesar/94eb2dee102a64952c53788d8866b13a to your computer and use it in GitHub Desktop.
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
| from selenium import webdriver | |
| from PIL import Image | |
| import os.path | |
| options = webdriver.ChromeOptions() | |
| options.add_argument('user-data-dir=/usr/local/google/home/christiannec/.config/google-chrome/Profile_01') | |
| options.add_argument("--start-maximized") | |
| driver = webdriver.Chrome(executable_path="/usr/local/google/home/christiannec/ChromeBrowserDriver/chromedriver_01", options=options) | |
| locales = ['en-US'] | |
| for locale in locales: | |
| path = "/usr/local/google/home/christiannec/Element_Screenshot/" + locale | |
| if not os.path.exists(path): | |
| os.makedirs(path) | |
| driver.get('https://admanager-ics.corp.google.com/6974#home') | |
| filenames = ['001_overview-card', '002_overview-card', '003_overview-card', '004_overview-card', '005_overview-card', '006_overview-card'] | |
| for filename in filenames: | |
| print('Press ENTER to take screenshot') | |
| os.system('read -s -n 1 -p "Press any key to continue..."') | |
| element = driver.find_element_by_css_selector("customizable-scrolling-material-tab-strip") | |
| location = element.location | |
| size = element.size | |
| driver.save_screenshot(path + '/' + filename + '.png') | |
| x = location['x'] | |
| y = location['y'] | |
| width = location['x']+size['width'] | |
| height = location['y']+size['height'] | |
| im = Image.open(path + '/' + filename + '.png') | |
| im = im.crop((int(x), int(y), int(width), int(height))) | |
| im.save(path + '/' + filename + '.png') | |
| driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment