不用截图,你直接在开发中工具拿到图片的地址连接就可以了
img = driver.find_element_by_xpath('')
location = img.location
size = img.size
top, bottom, left, right = location['y'], location['y'] + size['height'], location['x'], location['x'] + size['width']
screenShot = driver.get_screenshot_as_png()
screenShot = Image.open(BytesIO(screenShot))
img = screenShot.crop((int(left), int(top), int(right), int(bottom)))
img.save('filename.jpg')
以前写的截取滑动验证图片,不知道还能不能用