I am trying to access an element from the web which is not visible in the default view of the page(you need to scroll down little bit to get to that element). Is there a way to avoid scrolling and selenium picks it up wherever from the whole page it finds the element as the CSS/Xpath exists. If I scroll down the element gets identified. So its the matter of current view that selenium takes into account.
Thanks, RV
Selenium needs an element visible in the ViewPort to .click() on it. If you wanted to click on it without scrolling, use the JavaScriptExecutor:
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click()", element);
You could scroll down to the element via JavaScript, too:
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element);