Open linix999 opened 2 years ago
You should use the duration
parameter of ActionChains()
thx! it's the better way to solve this problem。
Btw if you need your mouse going slower for interacting with sliders you'll want to use a custom move_by_offset(x, y)
action...
Here is a very naive version that I use for simple captchas:
from selenium.webdriver.common.action_chains import ActionChains
class EnhancedActionChains(ActionChains):
def smooth_move_by_offset(self, dx, dy, n_step=50):
def get_displacements():
step_x = dx / n_step
step_y = dy / n_step
for i in range(n_step):
yield (
round((i + 1) * step_x) - round(i * step_x),
round((i + 1) * step_y) - round(i * step_y),
)
# pylint: disable=protected-access
self.w3c_actions.pointer_action._duration = 0
for ddx, ddy in get_displacements():
self.w3c_actions.pointer_action.move_by(ddx, ddy)
return self
thx!
adjust DEFAULT_MOVE_DURATION in seleniuim/webdriver/common/actions/pointer_input.py file take no effect。
in origin selenium==4.0.0a3 this param has effect。