I'm writing e2e tests for a large angular 4 project. I wrote a helper function to close a modal dialog if it exists. Previous operations might have automatically closed the dialog, based on conditional data, so I can't assume that a dialog is up.
function closeModal() {
Util.logInfo('closing');
$('.modal-backdrop').isPresent().then(exists => {
if (exists) {
< HANDLE CLOSING DIALOG HERE >
}
});
Util.logInfo('closed outer');
}
This code works fine, but what I'm seeing is that when the modal is up, checking for the existence of the modal always takes 10 seconds. I've rewritten this block using element
, element.all
, .length
, count()
, isPresent
, checking for elements on the dialog, and probably a few other ways I can't remember. No matter what I try, every time it takes a full 10 seconds for the promise to resolve when '.modal-backdrop'
doesn't exist. If it does exist this code including my logic executes in about 0.2 seconds.
Modal not up:
13:06:47:431 - ** closing
13:06:57:451 - ** closed outer
Modal Up:
13:06:57:563 - ** closing
13:06:57:705 - -> action: waiting for NOT presence of element up to 5000ms
13:06:57:718 - ** closed outer
This block gets called a lot, and probably 20% of the time it doesn't need to be closed (but I still need to call it just in case to prevent false failures), and it's adding about 30-40 seconds to each test run.
Is there anyway to speed this up, or at least temporarily change the timeout needed while in this block?