Many sites and web applications are using iframe elements tocreate tabs or sections on the page which the user can enable/disable/move at will. These often are being created in such a way that putting an ID on each frame is difficult or not feasible. As each frame is created or destroyed, of course, the index of a given frame within the frames collection changes. These factors combine, making it very difficult for an automation framework to reliably locate elements within the frames.
Beginning with the R2 release, Test Studio 2013 introduces Custom Tags for Frames, a way to specify frames that helps test automation engineers work with these scenarios. Tagging a frame allows Test Studio to reliably locate it and its child elements even as the frame's index or other attributes change.
First, you'll need to add a tag to the frame. This can either be done by the in the site's code or it can be added in a Test Studio coded step.
If you have access to the application's source or can work with the developers, the more flexible option would be to add the custom 'testStudioTag' attribute to the frame element. This makes the tag available for all tests that might need it.
<iframe TestStudioTag="MyCustomTag" ... >
The other option is to use a coded step in Test Studio to create the tag.
Create a new test which simply navigates to the correct page and verifies an element within the frame.
Next view the code behind the test, and add the a using directive for ArtOfTest.WebAii.Design.Extensions if it's not already in place.
Now you'll add a coded step, using the button in the toolbar.
If you have nested frames, you'll need to ensure that the entire DOM has been built, using the
The rest of the code sample selects a given frame from a 0-based array, then uses the TagFrame method to add the attribute to that element.
With the custom tag added using either of the above methods, open the Element Explorer. Locate the frame and open expand the FrameInfo property panel. Enter your custom tag name into the Tag field.
Test Studio will locate the frame and all child elements correctly.
During runtime the frame's custom tag takes precedence over the rest of the options - if an ID did exist it would now be ignored.
The feature is cross-browser and also supports nested frames scenario. The only known limitation is related to the browser security - some browsers are unable to access frames in a cross-domain context.
is an Evangelist for Telerik's Test Studio.
He has worked in software support and testing for the better part of two decades, and enjoys exploring ways to make software easier to use.
He is a fan of movies and music, and can often be found on Twitter as @StevenJV.
Copyright © 2016, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.