Can´t access iFrame in iFrame

18 posts, 1 answers
  1. Silvio
    Silvio avatar
    52 posts
    Member since:
    Dec 2012

    Posted 06 Feb 2013 Link to this post

    Hi,

    I can´t manage to access an iFrame within an other iFrame. I can find it with
    browser.Find.ByExpression("tagname=iframe")

    but can´t access it with
    browser.Frames[0]

    This causes an IndexOutOfRangeException. I tried to refresh the DomTree and also tried to reload the frame, but without success.

    Do you have any idea how to solve this?

    Kind regards
    Silvio
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 08 Feb 2013 Link to this post

    Hello Silvio,

    I am sorry to hear you are running into this issue.

    Please check out this forum post. We had a similar issue there.

    It seems your find expression is not unique, if you have multiple iFrames "browser.Find.ByExpression("tagname=iframe")" will find the first one only.

    Another thing is that you should use "ActiveBrowser" instead of browser.

    Please try to refresh the DOM tree just before the find expression. I recorded a short video as a demonstration.

    If this doesn't help please provide some more detailed information about your scenario.

    1. Please provide a Jing video or some screenshots demonstrating the issue you are experiencing.

    2. Please send us the test project and give us a direct access to the application (or create a simple one) so we can reproduce the issue on our end and give you a working solution.

    3. Alternatively you can record a Fiddler trace using FiddlerCap and send it to us in a zip file. Basically with that trace I'll try to "simulate" your app in order to reproduce the problem locally.

    Thank you for your cooperation. 

    Regards,
    Boyan Boev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Silvio
    Silvio avatar
    52 posts
    Member since:
    Dec 2012

    Posted 08 Feb 2013 Link to this post

    Hi,

    thanks for your help!
    This is the situation:
    The frame (Browser) saved in the variable "browser" contains only one iFrame. When I search for it with "browser.Find.ByExpression("tagname=iframe")" it will be found. But when I call browser.Frames[0] I get an IndexOutOfRangeException, so there is no frame in the collection. I already refreshed the DomTree, but this didn´t change anything.

    Unfortunately I can´t provide any specific code or video because this is not allowed in our company. And I don´t know any public site where I could demonstrate it.

    But it looks like following:

    <iframe src="outerBrowserFrame.html">
      <iframe src="innerFrameIWantToFind.html">
        <span id="innerCode" />
      </iframe>
    </iframe>

    The outerBrowserFrame.html-frame is saved in the variable "browser".
    "browser.Find.ByExpression("tagname=iframe")" results the innerFrameIWantToFind.html-frame. I can get the src-attribute without any problems.
    "browser.Frames.Count" results 0.
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 11 Feb 2013 Link to this post

    Hello Silvio,

    Let's clarify why you are using nested iFrames? The second iFrame will never render on the page therefore Test Studio can't find him.

    If I don't understand you correctly please send us the entire code you are using for locating the iFrame. Also send us just a code snippet of your HTML.

    Hope to hear from you soon.

    All the best,
    Boyan Boev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Silvio
    Silvio avatar
    52 posts
    Member since:
    Dec 2012

    Posted 11 Feb 2013 Link to this post

    Hi,

    I don´t use Test Studio, but the framework.
    The second iFrame is an Calendar, and it works. Even if I´m not able to access it per code.

    Like I told you before I unfortunately can not send you any specific code, but the sample exactly shows the situation (of course there are more elements contained in the frames, but they don´t matter).

    If I find the time I´ll try to find a public site with a similar scenario to create a sample project.
  6. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 12 Feb 2013 Link to this post

    Hi Silvio,

    We need to reproduce this behavior on our end to give you a working solution. 

    You can record also a Fiddler trace using FiddlerCap and send it to us in a zip file as I mentioned in my previous post . We can try to "simulate" your app in order to reproduce the problem locally.

    Another option is to find a similar public site so we can reproduce it there.

    Thanks for helping us advise you.

    Kind regards,
    Boyan Boev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  7. Silvio
    Silvio avatar
    52 posts
    Member since:
    Dec 2012

    Posted 25 Mar 2013 Link to this post

    Hi,

    sorry for the late reply. After I had much other work I´m now back to this problem.

    One more try to clarify what I mean:

    Ich have a browserwindow which contains an iframe. And this iframe or rather the content of this iframe contains another iframe. Of course the the frames are not nested exactly like in the example above. This example was just to show you what I mean.

    Maybe this is a better example:

    index.html:
    <html>
    <head>
    <title>IFrame Test</title>
    </head>
     
    <body>
    <iframe id="frame1" src="frame1.html" />
    </body>
    </html>

    frame1.html:
    <html>
    <head>
    <title>IFrame Test - Frame1</title>
    </head>
      
    <body>
    <iframe id="frame2" src="frame2.html" />
    </body>
    </html>

    frame2.html:
    <html>
    <head>
    <title>IFrame Test - Frame2</title>
    </head>
       
    <body>
    <span id="contentOfThisFrame">This is the content of this frame and the content I want to get</span>
    </body>
    </html>

    Now I can´t get the content of frame2. I can find it with

    frame1.Find.ByExpression("tagname=iframe", "id=frame2");

    but cannot access it. However, the frame-collection of frame1 is empty.

    Kind regards
    Silvio
  8. Answer
    Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 27 Mar 2013 Link to this post

    Hello Silvio,

    Thank you for the clarification.

    You don't need to locate the second frame under the first one. All two frames are rendered on the page, so you should locate directly the second one:

    HtmlSpan span = ActiveBrowser.Frames[1].Find.ById<HtmlSpan>("contentOfThisFrame");
    Log.WriteLine(span.InnerText);
     
    I recorded a short video as a demonstration against a sample HTML application.

    Let me know if this helps.

    Kind regards,
    Boyan Boev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  9. Silvio
    Silvio avatar
    52 posts
    Member since:
    Dec 2012

    Posted 28 Mar 2013 Link to this post

    Hi,

    Thanks for your help. This is a solution I'd never guessed.

    Kind regards
  10. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 28 Mar 2013 Link to this post

    Hi Silvio,

    Great! I am glad to hear that this issue is resolved. 

    Please don't hesitate if you have additional questions. 


    Regards,
    Boyan Boev
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  11. Hatem
    Hatem avatar
    7 posts
    Member since:
    Mar 2014

    Posted 02 Jul 2014 Link to this post

    I have a similar issue

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <body>
            <div>
                <iframe id="page1" name="page1" src="page1.html" frameborder="0" scrolling="no"></iframe>
            </div>
            <div>
                <iframe id="page2" name="page2" src="page2.html" frameborder="0" scrolling="no"></iframe>
            </div>
        </body>
    </html>

    For this HTML I get frames count equals zero when using IE but with Firefox I get the count is 2.

    Thanks,
    Hatem.
  12. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 07 Jul 2014 Link to this post

    Hello Hatem,

    I will need some more information on this issue since I am not able to reproduce it. I am using IE10 and I am getting the number of frames as I am supposed to. With Firefox browser I get the same. 

    Here is a sample video demonstration (no audio) on how this is working on my end.

    You can try to add a refresh DOM step and see if you will get the right count. Please find the sample code below:

    Manager.ActiveBrowser.Frames.RefreshAllDomTrees();
    var framesCount = Manager.ActiveBrowser.Frames.Count;
    Manager.Log.WriteLine(framesCount.ToString());


    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  13. Hatem
    Hatem avatar
    7 posts
    Member since:
    Mar 2014

    Posted 07 Jul 2014 in reply to Ivaylo Link to this post

    Hmmm...

    Looks like the version I'm using doesn't contain ArtOfTest.WebAii.Core.Browser.RefreshAllDomTrees()

    I'm using ArtOfTest.WebAii.dll v4.0.30319

    I expect RefreshAllDomTrees() to fix my issue, I'll keep you posted if I get any update.
  14. Hatem
    Hatem avatar
    7 posts
    Member since:
    Mar 2014

    Posted 07 Jul 2014 in reply to Ivaylo Link to this post

    You can ignore my last post, I figured out it's meaningless :) sorry for that.

    But
    in your video I noticed the page1.html & page2.html were not found,
    so I made the same referencing pages that doesn't exist and the count
    is as supposed, but when pages referenced are there the count is 0 !!!

    here is the html for the pages I used

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <head>
            <title></title>
        </head>
        <body>
            page1
        </body>
    </html>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <head>
            <title></title>
        </head>
        <body>
            page2
        </body>
    </html>
  15. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 10 Jul 2014 Link to this post

    Hi,

    I'm sorry but I got confused by your last responses. The video Ivaylo recorded only demonstrates the frames API returning the correct count.

    Can you please submit a support ticket attaching an exact test case demonstrating the problem you experience? That will help us identify the particular issue and assist you further.

    I'd also recommend running latest versions of the products which includes all the improvements we've included so far.

    Regards,
    Konstantin Petkov
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  16. Hatem
    Hatem avatar
    7 posts
    Member since:
    Mar 2014

    Posted 10 Jul 2014 Link to this post

    Hi,

    Here is the code I'm using with NUnit

    using ArtOfTest.WebAii.Core;
    using NUnit.Framework;

    namespace SomeNamespace
    {
        public class WebAiiTests
        {

            [Test]
            public void FramesTest()
            {
                var webAiiSettings = new Settings();
                var webAiiManager = new Manager(webAiiSettings);
                webAiiManager.Start();
                webAiiManager.LaunchNewBrowser(ArtOfTest.WebAii.Core.BrowserType.InternetExplorer);
                var browser = webAiiManager.ActiveBrowser;
                var path = TestContext.CurrentContext.TestDirectory;
                path = "file://" + path.Replace("bin\\Debug", "") + "_fixtures\\index.html";
                browser.NavigateTo(path);
                var frames = browser.Frames;
                frames.RefreshAllDomTrees();
                Assert.IsTrue(frames.Count.Equals(2), string.Format("Count was not 2 but {0}", frames.Count));
            }

        }
    }

    index.html contains

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <body>
            <div>
                <iframe id="page1" name="page1" src="page1.html" frameborder="0" scrolling="no"></iframe>
            </div>
            <div>
                <iframe id="page2" name="page2" src="page2.html" frameborder="0" scrolling="no"></iframe>
            </div>
        </body>
    </html>

    page1.html contains
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <head>
            <title></title>
        </head>
        <body>
            page1
        </body>
    </html>

    page2.html contains
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <head>
            <title></title>
        </head>
        <body>
            page2
        </body>
    </html>

    In this case I get frames count equals 0

    when I change index.html to
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <body>
            <div>
                <iframe id="page1" name="page1" src="page_that_doesnt_exist.html" frameborder="0" scrolling="no"></iframe>
            </div>
            <div>
                <iframe id="page2" name="page2" src="page2.html" frameborder="0" scrolling="no"></iframe>
            </div>
        </body>
    </html>

    In this case I get frames count equals 1

    When I change index.html to
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <body>
            <div>
                <iframe id="page1" name="page1" src="page_that_doesnt_exist.html" frameborder="0" scrolling="no"></iframe>
            </div>
            <div>
                <iframe id="page2" name="page2" src="another_page_that_doesnt_exist.html" frameborder="0" scrolling="no"></iframe>
            </div>
        </body>
    </html>

    In this case I get frames count equals 2 as expected

    I'm using ArtOfTest.WebAii.dll, v4.0.30319

    My browser is IE 8.0, and I'm using a 64 bit OS

    Tell me if you need any other details.

    Thanks,
    Hatem.
  17. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 14 Jul 2014 Link to this post

    Hello Hatem,

    I was not using IE8 and thought that is why I am not reproducing the behavior described. However using a virtual machine with IE8 and the latest Test Studio I was not able to reproduce the behavior as well.

    See this short video.

    Unfortunately without a reliable repro I cannot continue investigating this behavior.

    Thank you for your understanding regarding this matter.

    Regards,
    Ivaylo
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  18. ruthjchav
    ruthjchav avatar
    1 posts
    Member since:
    Jul 2014

    Posted 26 Jul 2014 in reply to Boyan Boev Link to this post

    Thanks for the video. It helped me a lot.
Back to Top