How to work with hidden buttons, when you have to click without using id?

There is an easier way to work around the problem using JavascriptExecutor.

For example:

The above javascript would click, even if it is hidden (hypothetically).

All you need to do is issue this JS instruction via the JavascriptExecutor interface like:


This would use the JS sandbox and synthetic click event to perform the click action. Although it defeats the purpose of WebDriver user activity simulation, you can use it in niche scenarios like in your case to good effect.

To receive daily posted JOBS & Interview Questions
Just enter your email address below and click 'Submit'
Enter your email address:

Make sure to activate your subscription by clicking on the activation link sent to your email