Page 1 of 1

How to detect whether a modal dialog is blocking mouseclicks

Posted: Tue May 23, 2017 2:31 pm
by uhmdown
Is there an elegant way to detect whether a button is unclickable because there is a modal popup present?
(modal = grabs focus and doesn't let go before it is closed again).
The button is visible and enabled, so the script thinks it can go ahead and click the button, when it in fact can not (due to the popup).

A PopupWatcher is trying to handle the popup, but an attempt to click the button is made too early, before the PopupWatcher closes the popup.

Of course, I could insert an excessively long delay to make sure the PopupWatcher always has time to finish, or I could have some loop that repeated tries to click the button until it succeeds, but I was hoping for something more elegant.

is there a smarter way to do this?

Re: How to detect whether a modal dialog is blocking mouseclicks

Posted: Tue May 23, 2017 3:11 pm
by odklizec
Hi,

The problem of popup watcher is that it runs in a second thread, which cannot pause/stop the main thread ;) This is why the test script continues without waiting for popupwatcher actions.

As for evaluating clickability of a button blocked by modal dialog, I think you can try evaluate "Enabled" attribute of given button? I would expect this attribute to be "false" if modal dialog is up? Eventually, you can add @enabled='True' attribute directly to the xpath of given button (in repository). Which means your script will click the button is enabled. Hope this helps?