Frame support is comming in the next release of LTAF. All the pieces are in the April release already but the public API to expose it is missing, you can look this post
http://forums.asp.net/t/1412750.aspx for a discussion of how to enable it for the current release.
This is an example of how a test will look like that automates an iFrame (part of our sample app that will also be released):
[WebTestMethod]
public void PageWithIFrame()
{
HtmlPage page = new HtmlPage("TestFrameSet.htm");
// get bottom frame
HtmlPage bottomFrame = page.GetFramePage("bottomFrame");
// verify title of frame
Assert.AreEqual("This is the bottom frame with an iFrame", bottomFrame.Elements.Find("h1", 0).GetInnerText());
// get the iFrame
HtmlPage iFrame = bottomFrame.GetFramePage("theIFrame");
//click on a button in frame
iFrame.Elements.Find("ChangeSpanButton").Click();
Assert.AreEqual("Button has been clicked", iFrame.Elements.Find("TheSpan").GetInnerText());
}
///
<summary>
/// The target frame to execute the commands against
///
</summary>
public
string TargetFrame
{
get {
return _targetFrame; }set { _targetFrame
= value; }
}
///
<summary>
/// Indicates value to use the target frame for command execution
///
</summary>
public
bool UseTargetFrame
{
get {
return _useTargetFrame; }set { _useTargetFrame
= value; }
}
And my test case looks like this:
HomePage.TargetFrame = "Frame3IFrameMain"; //HomePage property represents homepage with frames...
HomePage.UseTargetFrame =
true;
HtmlElement iL = HomePage.Elements.Find("slGroups_a",
MatchMethod.Contains);
iL.Click(
WaitFor.Postback);
Many Thanks....
Now waiting for next release so we can run test cases more efficiently in single new window. Or can you provide any private code now which will behave like feature itself?
Unfortunately, it is unlikely that I'll get to implement the auto run all tests on a popup window for the next release (coming first week of June). It is on our list of work items, but there are several other features ahead of it that are taking more time
(plus the QA team has been very busy testing .NET 4.0).
I can definetly send you a private build once I have it.
- Federico
Marked as answer by osbornm on Oct 10, 2009 12:16 AM
FRMJiggs
Member
4 Points
5 Posts
How can I find child elements of iFrame which is an element of the page?
May 04, 2009 07:21 PM|LINK
Hi,
Can anyone help me with the way to find any child element of the iFrame control?
All I can get is the Iframe control itself but its child elements count is 0.
iFrame control is being navigated dynamically, i.e. based on user action on the page.
Thanks
Jignesh
child elements iFrame
- Jignesh
qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: How can I find child elements of iFrame which is an element of the page?
May 05, 2009 05:34 AM|LINK
Hi,
Javascript Source...
document.frames("PageTwo").document.forms("Members").elements("Search").value
Or check the Link below
http://pietschsoft.com/post/2004/08/12/JavaScript-How-to-get-value-from-nested-form-in-iframe.aspx
http://www.dyn-web.com/tutorials/iframes/
Hope it helps
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
FRMJiggs
Member
4 Points
5 Posts
Re: How can I find child elements of iFrame which is an element of the page?
May 05, 2009 01:32 PM|LINK
Thanks for the reply...
However it will not help me as I am looking a solution in LTAF (which this forum belongs to), not in javascript.
Thanks anyways,
Jignesh
- Jignesh
farmas
Participant
1164 Points
259 Posts
Microsoft
Re: How can I find child elements of iFrame which is an element of the page?
May 05, 2009 04:33 PM|LINK
Hello Jignesh,
Frame support is comming in the next release of LTAF. All the pieces are in the April release already but the public API to expose it is missing, you can look this post http://forums.asp.net/t/1412750.aspx for a discussion of how to enable it for the current release.
This is an example of how a test will look like that automates an iFrame (part of our sample app that will also be released):
[WebTestMethod] public void PageWithIFrame() { HtmlPage page = new HtmlPage("TestFrameSet.htm"); // get bottom frame HtmlPage bottomFrame = page.GetFramePage("bottomFrame"); // verify title of frame Assert.AreEqual("This is the bottom frame with an iFrame", bottomFrame.Elements.Find("h1", 0).GetInnerText()); // get the iFrame HtmlPage iFrame = bottomFrame.GetFramePage("theIFrame"); //click on a button in frame iFrame.Elements.Find("ChangeSpanButton").Click(); Assert.AreEqual("Button has been clicked", iFrame.Elements.Find("TheSpan").GetInnerText()); }- Federico
FRMJiggs
Member
4 Points
5 Posts
Re: How can I find child elements of iFrame which is an element of the page?
May 15, 2009 12:42 AM|LINK
Hi Federico,
I was able to get the frame elements by the way you suggested in earlier post. However I tried to make it more generic as mentioned in following code:
HtmlPage.cs ... public BrowserInfo ExecuteCommand(BrowserCommand command){
command.Target.WindowIndex = this.WindowIndex;if (this.WindowIndex > 0){
command.Description += String.Format(" (Popup window: {0})", this.WindowIndex);}
if (_useTargetFrame && !string.IsNullOrEmpty(_targetFrame)){
command.Target.FrameHierarchy = new string[1] { _targetFrame };}
BrowserInfo browserInfo = this._commandExecutor.ExecuteCommand(Thread.CurrentThread.ManagedThreadId, command, EXECUTE_COMMAND_TIMEOUT); ...}
Some public properties in HtmlPage.cs...
/// <summary> /// The target frame to execute the commands against /// </summary> public string TargetFrame{
get { return _targetFrame; }set { _targetFrame = value; }}
/// <summary> /// Indicates value to use the target frame for command execution /// </summary> public bool UseTargetFrame{
get { return _useTargetFrame; }set { _useTargetFrame = value; }}
And my test case looks like this:
HomePage.TargetFrame = "Frame3IFrameMain"; //HomePage property represents homepage with frames...HomePage.UseTargetFrame =
true; HtmlElement iL = HomePage.Elements.Find("slGroups_a", MatchMethod.Contains);iL.Click(
WaitFor.Postback);Many Thanks....
Now waiting for next release so we can run test cases more efficiently in single new window. Or can you provide any private code now which will behave like feature itself?
- Jignesh
farmas
Participant
1164 Points
259 Posts
Microsoft
Re: How can I find child elements of iFrame which is an element of the page?
May 15, 2009 12:56 AM|LINK
Hey Jignesh, I am glad that it worked out for you. The next release already includes improved frame support, code looks like this:
HtmlPage framePage = originalPage.GetFramePage("TheNameOfTheFrame");
Unfortunately, it is unlikely that I'll get to implement the auto run all tests on a popup window for the next release (coming first week of June). It is on our list of work items, but there are several other features ahead of it that are taking more time (plus the QA team has been very busy testing .NET 4.0).
I can definetly send you a private build once I have it.
- Federico