Forum Discussion

Novari-QA's avatar
Novari-QA
Frequent Contributor
7 years ago
Solved

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.WaitPro...
  • tristaanogre's avatar
    7 years ago

    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.

  • tristaanogre's avatar
    7 years ago

    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.