Search Here!

Monday, April 29, 2013

Selenium : Scroll Automatically Before Click On Element

If you want to click() on a WebElement, but it is not showing because it is in invisible state. So, we need scroll the WebElement to make it in visible state and perform click() action.

((JavascriptExecutor) webDriver).executeScript "arguments[0].scrollIntoView(true);", webelementObject); 

1 comment:

  1. I cannot use this code. I am using Capybara, Selenium and chromedriver. What should I change to make this code work? Should I make instance for webelement, or smt like that? Can you tell me how to do it?

    ReplyDelete