# 1、悬浮在指定元素上方:
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
url = "http://dun.163.com/trial/picture-click"
driver.get(url=url)
# driver.find_element_by_class_name('yidun_tips').click()
# 准备悬停的元素
move_element = driver.find_element_by_class_name("yidun_tips")
# 悬停
ActionChains(driver).move_to_element(move_element).perform()
2、截图:
img1_element = driver.find_element_by_class_name('yidun_bgimg')
# 获取俩张图片
time.sleep(1)
img1_element.screenshot(r"D:\zjf_workspace\自己测试用的\验证码的破解\图文坐标\img1.png")
3、拼接图片
from PIL import Image
import matplotlib.pyplot as plt
img1 = Image.open(r"D:\zjf_workspace\自己测试用的\验证码的破解\图文坐标\img1.png")
img2 = Image.open(r"D:\zjf_workspace\自己测试用的\验证码的破解\图文坐标\img2.png")
# img3 = Image.open(r"D:\zjf_workspace\自己测试用的\验证码的破解\图文坐标\img3.png")
new_im = Image.new('RGB', (320, 200))
new_im.paste(img1, (0, 0))
new_im.paste(img2,(0,160,img2.size[0],160+img2.size[1]))
plt.imshow(new_im)
plt.show()