I want cut image from web page by python + Selenium, and remote debug by mstsc. Below is my code fragment:
image_data = self.driver.get_screenshot_as_png()
screenshot = Image.open(BytesIO(image_data))
screenshot.save('screenshot.png')
element = self.driver.find_element(By.CSS_SELECTOR,'myselect')
top = element.location['y']
bottom = element.location['y'] + element.size['height']
left = element.location['x']
right = element.location['x'] + element.size['width']
result = screenshot.crop((left,top,right,bottom))
But I can't get the image which I want. I open screenshot.png and find the real position by mouse, the value of (left,top,right,bottom) I got is different from the value calculated by the above code. So how can I get the real position of the image I want in web page?