fysh711426 / UndetectedChromeDriver

GNU General Public License v3.0
166 stars 60 forks source link

Web pages recognize mouse behavior #52

Open JvB94 opened 1 year ago

JvB94 commented 1 year ago

Is it vllt possible to write a function that clicks like a real user would do?

See https://stackoverflow.com/questions/39422453/human-like-mouse-movements-via-selenium

I can't get the implementation in C# right with the B-spinline. I often have the problem that he does not hit the element correctly and therefore does not click etc.

I would like to have a function that practically moves from the current mouse position to the desired element and then clicks it as desired or not. Gladly also a function that simulates random mouse movements so that this can not be detected.

It looks like this is currently the only problem why Undetected Chromedriver is detected.

Maybe that helps https://github.com/droefs/HLISA have someone a C# port?

gelistiricitr commented 1 year ago

Click(By.XPath("//div[@data-testid='Profile_Save_Button']"), driver);


 public static void Click(By by, IWebDriver driver)
        {
            IWebElement element = driver.FindElement(by);
            try
            {
                ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", (object)element);
                new Actions(driver).MoveToElement(element).Click().Build().Perform();
                Thread.Sleep(Helper.RandomNumber(100, 200));
            }
            catch
            {
                JSClick(element, driver);
            }
        }

public static void JSClick(IWebElement element, IWebDriver driver) => ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", (object)element);