Posts

Showing posts from November 21, 2018

Java - Wait for JavaScript event (e.g. onchange) to complete using Selenium

Image
up vote 0 down vote favorite A set of logically related input fields have an onchange event. After iterating over the fields and modifying their values some get updated correctly and some don't because of the stuff done by onchange event. The moment the onchange event triggers on a field, it starts some processing (involving other related fields), stores the value somewhere and clears other related fields if they weren't previously processed by their own onchange event. I could put the thread to sleep for an arbitrary amount of time but that doesn't look good. It would be just guessing how much time is going to take the processing and choosing between wasting time in a generous sleep or having a script that can abort due timeouts. Is there a way to know when the JavaScript code (which is called by the onchange