ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.69k stars 1.14k forks source link

selenium DEFAULT_MOVE_DURATION param no effect #541

Open linix999 opened 2 years ago

linix999 commented 2 years ago

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。

sebdelsol commented 2 years ago

You should use the duration parameter of ActionChains()

linix999 commented 2 years ago

thx! it's the better way to solve this problem。

sebdelsol commented 2 years ago

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
linix999 commented 2 years ago

thx!