定位后用imageGrab对img元素截图,代码如下:
checkcodeimg = browser.find_element_by_xpath("//img[@id='randimg']")
x1 = checkcodeimg.location['x']
y1 = checkcodeimg.location['y']
x2 = x1 + checkcodeimg.size['width']
y2 = y1 + checkcodeimg.size['height']
im=ImageGrab.grab(bbox=bbox)
im.save("H:/1.jpg")
问题是截出来的图片位置对不上
在java下按这个原理做是ok的 不知哪里出了问题