Targeting a dynamic element

4 posts, 1 answers
  1. Scott
    Scott avatar
    5 posts
    Member since:
    Nov 2014

    Posted 14 Nov 2014 Link to this post

    In my test I land on a page with a RoundContainer. When the test loads the page, the container can be either in an expanded or a collapsed state. The container uses an image to toggle the state of the container. If it's in an expanded state, it will have an image element where the src=minus.gif. If it's in a collapsed state, it will have an image element where the src=plus.gif.

    What I need the test to do is, if the container is collapsed when the page is loaded then expand the container by clicking on the image element (plus.gif). The problem is, if I target that element (plus.gif) and the test runs where the page loads the container in an expanded state, then the test will fail because it can't find the image element where src=plus.gif.


    What are my possible solutions?
  2. Answer
    Cody
    Admin
    Cody avatar
    3354 posts

    Posted 19 Nov 2014 Link to this post

    Hi Scott,

    This is pretty easy to handle actually. Start by adding a test step "Verify element exists" where src=plus.gif. Now use this Verify step as the condition of a logical IF/ELSE block. When you run the test if Test Studio can find src=plus.gif it will execute he IF block which should have the steps to click the Plus symbol thus expanding the item. Otherwise the ELSE block will execute which can be empty, i.e. do nothing.


    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. Scott
    Scott avatar
    5 posts
    Member since:
    Nov 2014

    Posted 20 Nov 2014 in reply to Cody Link to this post

    Ok, that was my thought pattern also. Before I created this forum thread, I designed my test with that logic built in but it failed when it could not find "plus.gif".

    After your reply, I re-wrote the test logic again from scratch and the test is now performing (and passing) as expected. I'm not sure what I did wrong the first time.

    Thanks for your help. I have marked this thread as answered.
  4. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 24 Nov 2014 Link to this post

    Hi,

    Excellent! Thank you for the update.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top