Ask a Question

WaitProperty on styles?

SOLVED
Novari-QA
Frequent Contributor

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;
} 

 

3 REPLIES 3
tristaanogre
Esteemed Contributor

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
tristaanogre
Esteemed Contributor

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Novari-QA
Frequent Contributor

Thank you that worked perfectly.

cancel
Showing results for 
Search instead for 
Did you mean: