WaitProperty on styles?
I am trying to wait on an object that i know exsists but the application needs to wait on the style="display: block;".
obj.WaitProperty("style", "display: block", 1); // doesn't work
obj.WaitProperty("Enabled", true, 1); //won't work because the object is enabled but the style is "display: none" until an operation is completed.
Thoughts? Ive tried this function ive created however, there has to be an easier way.
function YieldUntilVisibleOnScreen(obj, timeout = 10000) { var iteration = 0; var delay = 500; var maxIteration = timeout/delay; while(obj.VisibleOnScreen == false) { if(iteration >= maxIteration) return false; aqUtils.Delay(delay); iteration += delay; } return true; }
Have you tried just simply
obj.WaitProperty("VisibleOnScreen", true, -1);
Note that the third parameter is the wait time in milliseconds. -1 uses the default wait time in Project Properties Playback.
Now, if you need to specifically check a style setting... I don't know if this will help with the display one, but I use this for checking values of CSS styles applied to controls.
function getCSSProperty(element, prop){ var style; style = Aliases.browser.Page('*').contentDocument.defaultView.getComputedStyle(element, ''); return style.getPropertyValue(prop); } function checkCSSProperty(element, prop, checkValue){ var testValue; testValue = getCSSProperty(element, prop); if (checkValue == testValue){ Log.Checkpoint(prop + ' has value of ' + checkValue); } else { Log.Error(prop + ' value of ' + testValue + ' does not match ' + checkValue); } }
element is any onscreen object rendered by the web page. So, I pass the element in to checkCSSProperty, the text string of the property, and the value I'm looking for. When I run that piece of script, I get a verification of whether or not the CSS property matches the desired value. It would look something like this:
function foo(){ checkCSSProperty(Aliases.browser.myPage.myButton, 'background-color', 'rgb(153, 0, 0)') }
If the color matches, I get a checkpoint logged with the green check mark. If it doesn't, I get an error.
Perhaps this will help, too.