我就是举个例子,selenium 的 Actionchains使用可以参考这篇博客https://blog.csdn.net/jamieblue1/article/details/89856576
def canvas_move_right(self,move_d = 0):
driver = self.driver
actions = ActionChains(driver)
try:
if move_d <= self.width:
actions.move_to_element_with_offset(self.canvas, 0,0.5*self.height).perform()
time.sleep(0.2)
actions.click_and_hold(self.canvas).perform()
time.sleep(0.2)
actions.move_to_element_with_offset(self.canvas, move_d , 0.5 * self.height).perform()
time.sleep(0.2)
actions.move_to_element_with_offset(self.canvas, move_d , 0.5 * self.height).click().perform()
else:
print("一次移动距离过大,移动失败")
except Exception as Erro:
print(Erro)