I am trying to click on one of the hidden values but it is neither fetching nor it clicking on that value. I am trying for Indian railways berth availability wherein I want the source station value e.g. LUCKNOW ALAMBGH- AMV to get fetched and should accept that value.

What code can I write for accepting the value?

2 Answers 2


You can't click hidden elements with Selenium. However, you can trigger the click through Javascript, as found on SO:

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);
  • 1
    +1 for this clever trick. But whole point of browser automation, like Selenium, is to do what user can do, and have exactly same result as if user did it. If user cannot click on a hidden element, why it would make sense to allow Selenium to do it? OP is trying to do something strange. Mar 8, 2016 at 15:03
  • @PeterMasiar in the link posted in the answer, there is comment that says "overflow: hidden doesn't necessarily mean that it is hidden"
    – ilm
    Mar 8, 2016 at 17:32
  • I assume it will be hidden for the human user (no way to access it by clicking), but accessible via JS trickery like FDM's. It depends how you define "hidden" I guess. My definition is anthropocentric. :-) Mar 8, 2016 at 17:43
  • Can you tell me how it will click on the partial value e.g. LUCKNOW instead of the whole value. Mar 17, 2016 at 10:28
  • Change the selector for the webelement
    – FDM
    Mar 17, 2016 at 11:03

Simple way & working solution, When you want to take action on Hidden element

  1. First of all we know that element should be visible

    hidden_element.send_keys ""
  2. Once element get visible using selenium we can easily take any action


I hope code snippet will help you! Try it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.