selenium拖动元素
from selenium.webdriver import ActionChains
构造一个ActionChains对象,调用方法:
drag_and_drop_by_offset(self, source, xoffset, yoffset)
| Holds down the left mouse button on the source element,
| then moves to the target offset and releases the mouse button.
|
| :Args:
| - source: The element to mouse down.
| - xoffset: X offset to move to.
| - yoffset: Y offset to move to.
例:想把元素 a 向右平移10px
from selenium.webdriver import ActionChains
actions = ActionChains(driver)
actions.drag_and_drop_by_offset(a, 10, 0).perform()