Shoaib
Shoaib

Reputation: 88

How to scroll down properly in selenium C#

I have used actions class to scroll down but when it scrolls down click code is not working:

  driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
        
  Actions actions = new Actions(driver);
  actions.SendKeys(Keys.PageDown).Build().Perform();
       
       
 driver.FindElement("//a[@href='http://automationpractice.com/index.php? 
 controller=order&step=1']").Click();
        
 //var ele = driver.FindElement(proceed);
 //actions.MoveToElement(ele).Click().Perform();

enter image description here
Please use below id pass to login:

ID : [email protected]

Password : Pass123##

Upvotes: 0

Views: 2613

Answers (1)

sound wave
sound wave

Reputation: 3547

Instead of scrolling approsimatively with PageDown, you should perform scrolling to element in a precise way. Let me know if it works for you

var element = driver.FindElement("//a[@href='http://automationpractice.com/index.php?controller=order&step=1']");
actions.MoveToElement(element);
actions.Perform();
element.Click();

Upvotes: 0

Related Questions