Logical Loop Until Redirect

8 posts, 1 answers
  1. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 16 Oct 2013 Link to this post

    I want to implement a loop that will preform 2 statements a 'click' and a 'wait' till the page does a redirect how can I do this?

    Thanks
    Andrew
  2. Daniel
    Daniel avatar
    13 posts
    Member since:
    Aug 2013

    Posted 16 Oct 2013 Link to this post

    Are you trying to loop X number of times (http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/logical-steps/loop.aspx), or loop conditionally until another verification is met (http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/logical-steps/while-loop.aspx)?

    Simple loop demo and while loop demo (not good because it will go on indefinitely) attached.

    These are using a wait to determine that the page has indeed changed by checking the content of the name span.  You could do a coded step to verify against URL's, or any other sort of verification.

    If you need something more specific, please provide a bit more detail to help with the exact issue.

    **EDIT**

    A feature I've never used...there is a "Wait for URL" option: http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/add-custom-step/wait-for-url.aspx.

    Do you know URL's the automation should be going to?

  3. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 16 Oct 2013 Link to this post

    I would need to be a conditional loop, that would loop until the page redirects.

    I could to a coded step, but I was hoping to get it to work without doing that.

    if my while loops verification test could be on if the element exists or not then I would think that would
    work because the element would not exist of the new page. but I do not think you can do that.

    I tried this:
    WHILE (Verify element 'CphBaseMasterBodyCphAuthenticatedRightColumnEmCheckPDFStatusLinkButton1Link' 'is' visible.) THEN

    but is caused an error because the page redirects in the loop and the element being tested does not exist.
  4. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 16 Oct 2013 Link to this post

    I got it to work....  I opened up the dom and built the verification off the form action value.

    WHILE (Verify attribute 'action' has 'Contains' value of 'CheckPDFStatus.aspx' on 'Form1FormTag') THEN
  5. Daniel
    Daniel avatar
    13 posts
    Member since:
    Aug 2013

    Posted 16 Oct 2013 Link to this post

    Glad to hear you got it figured out.
  6. Answer
    Shashi
    Shashi avatar
    25 posts
    Member since:
    Feb 2011

    Posted 16 Oct 2013 Link to this post

    Andrew,

    You may also be able to implement this using While (Verify Not Exists) on an element on the page it redirects to - or While (Verify Exists) on an element on the page that you start on.  However, it takes multiple steps to construct this statement:

    a) FIrst record a Wait for Exists on the element of the destination page (if you are implementing the first option) or an element on the source page (if you are implementing the second option).
    b) Convert to Wait for Not Exists (if you are implementing the first option)
    b) Convert Wait to Verify (using the command on the Step Context menu).
    c) Convert to a WHILE loop using the command on the Step context menu.

    HTH,
    Shashi
    p.s. Telerik:  It would be good to have a command to directly record a Verify Exists statement (with UI workflow being same as that for Wait for Exists).
  7. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 17 Oct 2013 Link to this post

    I agree a Verify Exists statement  and a Verify NOT Exists statement would be good in the quick validations screen
  8. Mario
    Admin
    Mario avatar
    8 posts

    Posted 22 Oct 2013 Link to this post

    Hello Andrew/Shashi,

    @Andrew - I'm glad to see you were able to find a solution to your original problem.

    @Andrew/Shashi - Thank you both for the suggestion of adding Verify Exists/ExistsNot to the Quick Tasks menu, I have created this entry in our public Feedback portal for further consideration of this feature.

    Please let me know whether you have any additional questions.

    Regards,
    Mario
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!