Is there a way to force an object on the website into view?

Due to a client’s request we made our menu bar a floating object.
As I navigate through items in our form to process a job data change transaction against an employee occasionally objects are hidden behind the menu.

So when I execute the command:'Page_New Action - Job Data Change/btn-search-supervisor'))

I get the following error:

Test Cases/Staff Position JDC FAILED because (of) Unable to click on object ‘Object Repository/Page_New Action - Job Data Change/btn-search-supervisor’ (Root cause: org.openqa.selenium.WebDriverException: unknown error: Element Search Supervisor link is not clickable at point (1056, 8). Other element would receive the click: Tools

A quick search of the forum didn’t drum up any way to automatically make every object I go to interact with move towards the middle of the page away from the Menu at the top of the screen.

Any suggestions?


1 Like

Hi Greg

That looks like a royal pita…

I’m guessing that[WebUI]+Scroll+To+Element and[WebUI]+Scroll+To+Position aren’t going to help much here (but I could be wrong).

There is the Actions/interactions API:

It has a couple of drag operations:

Hope that helps. Let us know how you get on…


1 Like

Yeah the default operations detect that the object is in the ‘visible’ space of the webpage. But due to the floating menu it’s not clickable. At the moment I re-organized the test so that step is executed before it scrolls down.

I’ll take a look at those options though, because there are parts of our current test automation framework where we still needed this.


I did think of another way of doing it, but it would be bad. I mean, naughty-boy bad :wink:

Just prior to executing the problem test step, you could hide the parent-most element of the floating menu (using JavaScript and CSS), execute the test, then return the menu CSS to normal again.

But like I said, that would be bad, for the following reasons:

1 - Tests shouldn’t “pollute” the AUT if it can at all be avoided.

2 - It’s not something a regular user would (or even can) do.

However, if you have no choice, “when needs must” and all that…

Did we every come up with another work around? I’m having a similar issue, but my issue is screenshots. I have a banner that hovers to show we are in a test environment. When I scroll to the object to interact with it or screenshot it, it’s hidden by the banner…

We ended up writing a method we call ‘ensureVisible’

In our webapp the height of the menu is a fixed amount, so we declared that outside of the method calling it: MENU_OFFSET if it ever changed we only need to update that one value.


You should document what you mean by MENU_OFFSET (and any other externals this code relies upon).

Great care needs to be taken when presenting code as generic (e.g. “Ensures that an element is somewhere in the viewport”) when in fact it won’t work for anyone else.

Greg - I’m not beating you up. I make the same damn mistake all the time. I wrap calls to WebUI.executeJavaScript in a helper function called jsexec and usually forget to mention it. So looking at your code (too briefly, probably) I’d just remove that line since it’s local to you. But… your call.

Other than that, great solution! :sunglasses:

good catch I missed that. Yeah we declared the MENU_OFFSET cause it was a fixed value we knew we had to always deal with.