when UIs are slow I resort to using the find node to search for an element in conjunction with the wait option. Though, that necessitates to remove the added column of the found element.
The use case really just is to wait until an element is present indicating the website has fully loaded.
I’d like to suggest extending the regular wait node by some of the options from the find node like:
PS: It just flashed up in my mind to add an option to invert the result, i.e. wait until an element is not found. This correlates to some degree with the other feature suggestion of mine:
Though, I don’t want to ask for too much … just a suggestion
FYI and maybe for some sort of inspiration. I have put this JavaScript into place to leverage the Web Animations API.
So far my tests were positive but I did not manage to actually retrieve the callback value true, false or error.
/**
* Add your JavaScript code below:
*/
const callback = arguments[arguments.length - 1]; // last argument is callback
try {
// Select the element with the id "master"
const elementMasterOverlay = document.querySelector('#master');
// Function to handle transition end event for the "width" property
function handleTransitionEnd(event) {
// Check if the transitioned property is 'width'
if (event.propertyName === 'width') {
// Log the completion of the width transition
console.log('Width transition finished!', event);
// Remove the event listener to prevent memory leaks
elementMasterOverlay.removeEventListener('transitionend', handleTransitionEnd);
// Resolve the callback with "true" since the width transition is complete
callback(null, 'true');
} else {
// Resolve the callback with "false" if it's not the width transition
callback(null, 'false');
}
}
// Set up the transitionend event listener specifically for the width property
if (elementMasterOverlay) {
elementMasterOverlay.addEventListener('transitionend', (event) => {
if (event.propertyName === 'width') {
handleTransitionEnd(event);
}
});
} else {
// If the element is not found, throw an error to be caught
throw new Error('Element with ID "master" not found');
}
} catch (error) {
// Catch any errors and resolve the callback with "error"
console.error(error);
callback(null, 'error');
}
cannot check the code in detail at the moment, but here’s some advice which might help:
The last entry in the Arguments list called [asyncCallbackMethod] must be enabled.
The callback allows one single argument, so callback(null, true) will not give you the second argument in the result table - if you need more than one result value, use the List or JSON type. You could e.g. do like this and use the JSON return:
callback({ result: true });
callback({ result: false });
// can usually not serialize entire Error object,
// so specify your properties manually, e.g. message
callback({ error: error.message });
Thanks for your feedback. asyncCallbackMethod is enabled. The callback is only triggered during either if, else statement or the catch statement. Though, I noticed a warning which, despite me slowing down the scraping to human levels, could cause some issues which led me to submit this feature request:
Throttling navigation to prevent the browser from hanging. See . Command line switch --disable-ipc-flooding-protection can be used to
In Selenium Nodes version 5.9 which we released a few days ago there’s a new section Conditions which provides nodes for all kind of conditional wait constructs.
Also tagging you here @arjenex as I’m not sure if my recent email made it through: It addresses your use case of letting a workflow wait until an element on the page disappears using the Number of Elements and Wait for Condition node.
Or another typical use case: Keep paginating a result list and click the “Next” link until the end using a conditional loop, case switch and flow variables:
that are some phantastic news. Once I am out of the hostial with my daughter, I will take some time incorporating these to replace the JavaScript based fallback.