This is a migrated thread and some comments may be shown as answers.

Targeting a dynamic element

3 Answers 60 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 14 Nov 2014, 10:54 PM
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?

3 Answers, 1 is accepted

Sort by
0
Accepted
Cody
Telerik team
answered on 19 Nov 2014, 06:13 PM
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!
0
Scott
Top achievements
Rank 1
answered on 20 Nov 2014, 04:47 PM
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.
0
Cody
Telerik team
answered on 24 Nov 2014, 11:15 PM
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!
Tags
General Discussions
Asked by
Scott
Top achievements
Rank 1
Answers by
Cody
Telerik team
Scott
Top achievements
Rank 1
Share this question
or