webdriver保存验证码截图

element = wait.until ( EC.visibility_of_element_located((By.CSS_SELECTOR,'.quc-main .quc-field-captcha img')))  #等待验证码加载完毕


browser.save_screenshot('screenshot.png')


left = element.location['x']
top = element.location['y']
right = element.location['x'] + element.size['width']
bottom = element.location['y'] + element.size['height']


im = Image.open('screenshot.png')
im = im.crop((left,top,right,bottom))
im.save('screenshot.png')

转载于:https://www.cnblogs.com/BeyondTechnology/p/9780921.html

你可能感兴趣的:(webdriver保存验证码截图)