1
votes

I am using WebDriver with FireFox. I want to click on checkboxes that is currently not visible on my webpage. I am getting the error "Element is not currently visible and so may not be interacted with." As I search through Google for help, someone said that it would scroll automatically with click action. That is not the case for me.

Here is my code fragment

driver.findElement(By.name("inboundPriority")).click();

I have also tried

JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,2000)", "");

but failed. The scrollbar/webpage won't move.

Any help would be appreciated. Thanks.

3
Are you sure the item is visible? maybe something higher up the DOM is invisibleKeepCalmAndCarryOn
How do you check for invisible higher up the DOM? I still have the problem of not being able to scroll the webpage using WebDriver.CodeHelp

3 Answers

1
votes

I found the solution already. It has got to do with my css. Initially, I set overflow:auto at body. When I hide the overflow:auto, the javascript works and I can scroll the webpage.

0
votes

"Visible" means the display style (viz; the CSS), not whether not it is visible to humans at a particular moment in the broswer. If you open up the page source, is that element in there? When you say scroll, do you mean with the browser itself? That couldn't be the issue. I would also recommend making sure you are referring to the right element. You might find this answer helpful as well: Element is not currently visible and so may not be interacted with

0
votes

You can either use 1.JSExecutor to click on checkboxes depending on how many checkboxes are to be selected or any more actions are to be performed. 2.Use Java Robot class to scroll down page by pressing pagedown key.