When the desired iFrame is identified, there are no children to the iframe tag. Does this need to be cast to a new browser? Do I take the src attribute and use that within a new Browser element?
Any help would be appreciated.
15 Answers, 1 is accepted
Getting to the contents of an IFrame is pretty easy once you know the secret. Just use code like this:
// Get at the frame by name
Browser myFrame = ActiveBrowser.Frames[
"myFrameName"
];
// Get at the frame by index number
Browser myFrame = ActiveBrowser.Frames[0];
HtmlButton myButton = myFrame.Find.ById<HtmlButton>(
"myButtonID"
);
myButton.Click();
Does that answer your question? Regards,
Cody

It's already fix.. thx.. frame.RefreshDOmtree(); is used. thank you!!!

I am able to access the elements in IFrame but after that I am
unable to access the elements in the active browser:
I am posting the code I have written.
Element newElement = Manager.ActiveBrowser.Find.ByContent(
"New"
);
Manager.ActiveBrowser.Actions.Click(newElement);
Browser myFrame = Manager.ActiveBrowser.Frames[
"rbe_popupFrame"
];
Element ele = myFrame.Find.ByContent(
"A new Object (with Tab)"
);
myFrame.Actions.Click(ele);
Element create = myFrame.Find.ByAttributes(
"value=~Create"
);
myFrame.Actions.Click(create);
Manager.ActiveBrowser.RefreshDomTree();
Element singularName = Manager.ActiveBrowser.Find.ByName(
"singularName"
);
Manager.ActiveBrowser.Actions.SetText(singularName,
"Object1"
);
Here after clicking on New the IFrame will be open. And able to access the elements in the IFrame. The IFrame will be closed when we click on create. Then after that I want to enter the value in the textbox which is there in the browser. But after closing the IFrame I am getting time out exception.
InnerException:System.TimeoutException: Wait for condition has timed out
at ArtOfTest.Common.WaitSync.CheckResult(WaitSync wait, String extraExceptionInfo, Object target)
at ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout, WaitResultType errorResultType)
at ArtOfTest.Common.WaitSync.For[T](Predicate`1 predicate, T target, Boolean invertCondition, Int32 timeout)
at ArtOfTest.WebAii.Core.Browser.WaitUntilReady()
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request)
at ArtOfTest.WebAii.Core.Actions.Click(Element targetElement)
at new_test_project.WebTest_1_.WebTest1_CodedStep() in c:\Program Files(x86)\Telerik\Test Studio\Samples\Test Studio\DemoTests\WebTest(1).tstest.cs:line 384
Yes sometimes you do need to call RefreshDomTree();. We cache the browsers DOM in memory for performance reasons. There are instances in which the cached copy will get stale and RefreshDomTree updates it for you.
Notice this line from the stack trace:
at ArtOfTest.WebAii.Core.Browser.WaitUntilReady()
What's actually happening is that Test Studio is timing out waiting for the browser to return to the "Ready" state after performing the click. There are a couple of ways to handle this:
1) Increase the ClientReadyTImeout property. This will fix it if the current timeout is simply not long enough. I believe the default value is 30 seconds. Sometimes a click that causes an action on the backend to happen can take longer.
2) If the browser actually never returns to the "Ready" state, use a mouse click instead of the .Click like this:
Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, create.GetRectangle());
I hope this helps.
Regards,
Cody
Telerik
Test Studio Trainings

Hello David.
Thanks for handling IFrame. But I have a scenario, that is there is a PDF present in inside the IFrame. I have to verify the PDF content dynamically. There is no option available for to read the LIVE PDF content and also, the PDF content changes dynamically.
Any help would be appreciated.
Thank you for reaching us out.
Test Studio interacts with the html structure and html elements in it. The pdf content is not part of the html of the page and therefore Test Studio will not be able to read that content.
If you download the pdf file you could implement coded solution to read that file and perform verifications against it.
Please let me know if you need further assistance!
Regards,
Elena Tsvetkova
Progress Telerik
Test Studio Trainings

Hello,
I am facing issue in capturing the step to enter value in the html body with in a iframe.
here is my iframe.
<iframe id="description-2215-inputCmp-iframeEl" data-ref="iframeEl" name="ext-2104" frameborder="0" src="about:blank" class="x-htmleditor-iframe" data-componentid="description-2215">
<html>
<head>
<style type="text/css">body{border:0;margin:0;padding:3px;direction:ltr;min-height:192px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;cursor:text;background-color:white;font-size:12px;font-family:"Segoe UI"}</style>
</head>
<body style="font-size: 16px; font-family: "Segoe UI", Helvetica, Arial, sans-serif; background-image: none; background-repeat: repeat; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); background-attachment: fixed; cursor: text;">TestHello</body>
</html>
</iframe>
On recording, it is is capturing the iframe click step.
How to add the step of entering the test in the html body, here its "TestHello"
Any help would be appreciated.
Thanks and Regards,
Renjila

Hi ,
If you want to handle elements within IFrame, first you have to handle IFrame, then only we can handle elements within the IFrame.
Below mentioned the code.
Browser IFrame=_manager.ActiveBrowser.Frames.ById("description-2215-inputCmp-iframeEl"); /* To capture the IFrame using IFrame ID.*/
Element recObj = IFrame.Find.ById(locatorValue); /*With the help of IFramewe can handle the elements*/
recObj.Focus();
_manager.ActiveBrowser.Actions.SetText(recObj, "");
_manager.Desktop.KeyBoard.TypeText(value);
It will help you lot.
Regards,
Sakthi.

Hello Sakthi,
Thank you for the quick response.
In my scenario ,how to locate the body tag, as it does not have the id.
Element recObj = IFrame.Find.ById(locatorValue);
Regards,
Renjila Rajan

Hi ,
You can use XPath to capture the body tag.
Eg:
Element recObj = IFrame.Find.ByXPath("/html/body");
Regards,
Sakthi.

Hello Sakhti,
Thank you for your input.
Now the problem here is its throwing error in SetText method saying the element passed is null.
Pages.Https1013129.Description2217InputCmpIframeElIFrame.Click(false);
Pages.Https1013129.Description2217InputCmpIframeElIFrame.Refresh();
Browser IFrame=Manager.ActiveBrowser.Frames.ById("description-2217-inputCmp-iframeEl");
if(IFrame==null)
{
Log.WriteLine("frame is null");
}
Element recObj = IFrame.Find.ByExpression("TagIndex=html:0");
Element recObj2 = IFrame.Find.ByXPath("/html/body");
logValue(recObj);
logValue(recObj2);
if(recObj2!= null)
{
Manager.ActiveBrowser.Actions.SetText(recObj, "Hello");
}
When I checked in the DOM during runtime, I could see the html and body tag . Please let me know , what could be the issue for this null object then.
Thanks in advance
Renjila

oops! sorry! that was a minor mistake of variable. Its not that error. The issue here :
Target '[Element: 'body:0']' is not a supported element to set text to.

oops sorry! that was not the issue. that was because a typo.
The issue is Target '[Element: 'body:0']' is not a supported element to set text to.

Hello,
I couldn't get how to assign value to body tag ; however I used a workaround by focusing the IFrame and using TypeTest, which resolved my issue.
Thanks !
I am glad to see you collaborated on this issue. I hope it is all fine now. Though in case of further assistance required please do not hesitate to contact us again!
Regards,
Elena Tsvetkova
Progress Telerik
Test Studio Trainings