How to ScrollTo in C# after ScrollTo and ScrollToExact were deprecated

I have noticed that the ScrollTo was deprecated, but didn’t find any good solution to scrollTo any webelement.
can someone please help me figure out what’s the best way to do that now?
Thanks
Yaniv

Hi,

Could anyone suggest about this scroll to alternative.

Regards,
Vijay Bhaskar.

I have done something as follow (C#):

 public void SWipeUntilelementVisible(string ElementID)
    {
        var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5));
        var SendRequirementForScroll =   wait.Until(x => x.FindElements(By.Id(ElementID)));
       
            bool visible = false;
            int counter = 0;

            try
            {
                while (visible == false)
                {
                    if (counter == 0 && visible == false)
                    {
                        _driver.Swipe(1200, 1487, 1200, 732, 0);
                        counter++;
                    }

                    else
                    {
                        _driver.Swipe(1200, 1487, 1200, 732, 0);
                        var SendRequirementForScrollTmp = wait.Until(x => x.FindElements(By.Id(ElementID)));
                        if (SendRequirementForScrollTmp.Count > 0)
                        {
                            counter++;
                            visible = true;
                            Console.WriteLine("Element became visible");
                            break;
                        }
                    }
                    }
                }
           
            catch { }

     }

Please note that the x,y in swipe method I used depends on the screen itself.
So you either need more generic mehod calculating the screen and x,y or you can use a static values (as I did in this case). so , you are actually swiping a little bit each time until the element is being found.
this one done the job for me , but I’m sure you can improve this method.