I'm attempting to use a Selenium-based framework to test a company web page, but I'm encountering some errors wherein after I generate a report inside of a popup, and then close that popup and attempt to do more testing in my original window, I can no longer send keys to test fields in that window. I can click on html elements and navigate to new pages, and the sendKeys function is NOT throwing any errors, but no text is being entered into the targeted web element when it's called. There doesn't appear to be anything wrong with the web elements themselves - I can still enter text manually, and my scripts can use those same specific elements just fine as long as they haven't closed any popups beforehand, but once I close the popup involved in my test, Selenium stops sending text properly. Any input would be greatly appreciated.

closed as unclear what you're asking by NarendraC, Bharat Mane, kirbycope, FDM, Alexey R. Apr 23 '18 at 14:20

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What kind of pop-up is that? is it a separate window or en element of the DOM that is just overlays the original content? – Alexey R. Apr 13 '18 at 9:55


If sendKeys() doesn't work, check that your selector returns an editable element. You can't sendkeys to something that isn't an input. Even still some JS frameworksbind the data value so simply entering the keys isn't enough to trigger the "onchange"/"blur"/"focus"/whatever event. Check with your devs on this second point. If that is the case, I have used the JavaScriptExecutor to set the value and then trigger the necessary events.

-Original Answer-

Your WebDriver likely needs to switch back to original window after closing the pop-up. Here is a link to the documentation from SeleniumHQ. You can switch by index or window name. You can also hop between iFrames this way.

  • Doesn't appear to be working, unfortunately. And if this was the problem, why would my scripts still be able to see/get/click web elements, but just not be able to send keys to them? – CRoyse Apr 12 '18 at 18:13
  • If it helps, I can point out that the tests in question are generating/downloading reports within the popup - those reports can take the form of either HTML or PDF documents. I don't know if that could be confusing selenium somehow... – CRoyse Apr 12 '18 at 18:58
  • Be sure to check if this HTML/PDF is in an iFrame. iFrames are also covered in my SeleniumHQ link. – kirbycope Apr 12 '18 at 21:14

How are you identifying the element? ID? Css? XPath?

I ask because the popup may have changed the path from before it was created to after it was closed.

Picture this, the page originally has this path to the input field:


But the popup creates a new div node via JavaScript causing the field to now be:


You close the popup, but the div remains causing your path to be altered. sendKeys() works, but it's now pointing to some other field you cannot see, thus no error. The opposite could be true, in that the div is originally there but removed when the popup is closed.

It's a long shot, but based on

"...my scripts can use those same specific elements just fine as long as they haven't closed any popups beforehand..."

leads me to believe that the creation and/or closing of the popup is changing the DOM so you are no longer targeting the input field you are trying to fill.

I would think Selenium would throw an error in such cases, usually either Doesn't Exist, Invalid Element State, or Stale Reference, but it's worth a shot. Examine the path before, during, and after the popup.

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