I am writing automated test scripts for a project I am working on, using webdriver. During one of my scripts a “wheel of hope appears” on the page while a payment is being processed. All other elements are displayed on the page but the spinning wheel always takes focus. Hence I can’t click/interact with any elements on the page.
In general before clicking on an element I verify that it is on the page. My problem is
that the element is on the page but I am unable to click on it due to the wheel taking focus. Is there a way to verify that an element can have focus/be the active element? Otherwise I am stuck using explicit waits as my wait for jquery implicit wait doesn’t seem to work.
All ideas welcome.
Thanks,
James
My one thought is to use jquery to focus on the element, and then to only start the next action once the element has been focused on. Does anyone know if this would have limitations?
I tried to use the following to focus the element then verify focus:
arguments[0].focus();
if(document.activeElement==arguments[0]){
return true;
}
else{
return false
}
(where arguments[0] is the webelement behind the wheel of hope I want to click on). Unfortunately it returns true while the wheel is still spinning and taking away focus…
Assuming this “wheel of hope” is a masking element that covers the entire page, you should wait for it to be hidden or removed from the DOM before you try to interact with the underlying element (just as you would manually).