Forum Discussion

Oferv's avatar
Oferv
Super Contributor
13 years ago

Waitproperty,how do i wait for a field?

Hi,



i know the option to wait for a specific property to appear before move forward to the next step but in my case i need to wait for a field value to become false and i wonder if there's an option to do so? is it ["WaitWPFObject"]()?



Thanks

6 Replies

  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Ofer,


    Try using something like this:



    var appField = Sys["Window"]("Win_Name")["Field_Name"];

    while (appField == true)

      Delay(100);


    I hope this helps :)

  • Oferv's avatar
    Oferv
    Super Contributor
    Hi Irina,



    Thanks

    but what if i want to make sure the script won't get stuck if the property will never be equal to true?

    i would like to give it a certain amount of time to wait for this property to become true and if it's not by that time... do some thing...



    Thanks
  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Ofer,


    Hm...I would modify the script in the following way:



    var appField = Sys["Window"]("Win_Name")["Field_Name"];

    var i = 0; // The variable that controls the time

    if (i < 20)

    while (appField == true)

      {

      Delay(100);

      i++;

      }



    The code above will check the value of the property only 20 times with a 100-millisecond delay, that is, 20*0.1=2 seconds.


    I hope this helps :)

  • Oferv's avatar
    Oferv
    Super Contributor
    I thin WaitProperty is doing the job for field as it's doing for property. is it risky using WaitProperty  for a field value?



    Thanks
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    According to the help:



    Use the WaitProperty method to pause the test execution
    until the specified object property achieves the specified value or until the
    specified timeout elapses.




    So, what you are trying to do, wait for the value of a field to get to a certain point, is exactly what the wait property method was defined to do.