Python PIL saved black image -


i'm trying screenshot of phone element in site. save screenshot of entire page, element coordinates , crop screenshot in phone element place. after cropping got black image. don't understand why, , how can fixe it.

my code:

# coding: utf-8 selenium import webdriver selenium.webdriver.common.keys import keys selenium.webdriver.chrome.options import options selenium.webdriver.common.action_chains import actionchains selenium.webdriver.common.proxy import * import time pil import image  driver = webdriver.chrome(executable_path='chromedriver') driver.get('https://www.avito.ru/moskva/audio_i_video/televizor_samsung_i_tumba_iz_stekla_k_nemu_838296913') button = driver.find_element_by_xpath('//*[@id="i_contact"]/div[3]/div/span[1]/span') button.click() time.sleep(4) element = driver.find_element_by_xpath('//*[@id="i_contact"]/div[3]/div/span[1]') location = element.location size = element.size driver.save_screenshot('screenshot.png') driver.quit()  im = image.open('screenshot.png')  left = location['x'] top = location['y'] right = location['x'] + size['width'] bottom = location['y'] + size['height']   im = im.crop((left, top, right, bottom)) im.save('screenshot.png') 

screenshot after selenium save: enter image description here

screenshot after cropping:

enter image description here


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -