NullReferenceException with frames in IE9

2 posts, 0 answers
  1. Anton
    Anton avatar
    54 posts
    Member since:
    Sep 2011

    Posted 04 Oct 2012 Link to this post


    I have a problem with frames.

    My code:

    var frame1 = ActiveBrowser.Frames["leftFrame"];
    and Html:

    <frameset cols="*,70%">
    <frame scrolling="auto" src="/webstudio-test/faces/pages/modules/trace/tree.xhtml?first=true&uri=file%3A%2FC%3A%2Fopenl-tests%2Fuser-workspace%2Fa1%2FLLZIHOD%2Frules.xls%3Fsheet%3DRules%26range%3DB3%253AE13" name="leftFrame">
    <form id="j_idt5" enctype="application/x-www-form-urlencoded" action="/webstudio-test/faces/pages/modules/trace/tree.xhtml" method="post" name="j_idt5">
    <input type="hidden" value="j_idt5" name="j_idt5">
    <span class="traceTreeParams">
    <span id="j_idt5:traceTree">
    <div id="j_idt5:j_idt8" class="rf-tr tree">
    <div id="j_idt5:j_idt8:1:j_idt9" class="rf-tr-nd rf-tr-nd-colps rf-tr-nd-last">
    <div id="j_idt9" class="rf-trn">
    <span class="rf-trn-hnd-colps rf-trn-hnd"></span>
    <span class="rf-trn-cnt">
    <div id="j_idt5:j_idt8:1.1:j_idt12" class="rf-tr-nd rf-tr-nd-colps rf-tr-nd-last">
    <input id="j_idt5:j_idt8__SELECTION_STATE" class="rf-tr-sel-inp" type="hidden" value="" name="j_idt5:j_idt8__SELECTION_STATE">
    <script type="text/javascript">
    <input id="javax.faces.ViewState" type="hidden" autocomplete="off" value="3034330929021769213:-4432157085689481536" name="javax.faces.ViewState">
    <frame scrolling="auto" src="/webstudio-test/faces/pages/modules/trace/showTraceTable.xhtml?first=true&uri=file%3A%2FC%3A%2Fopenl-tests%2Fuser-workspace%2Fa1%2FLLZIHOD%2Frules.xls%3Fsheet%3DRules%26range%3DB3%253AE13" name="mainFrame">
    <noframes> <body> <p>To view content you need frames capable browser</p> </body> </noframes>

    In FF works fine but in IE9 throw exception: 

            • System.NullReferenceException: Object reference not set to an instance of an object at click method.
            • Env: Win7 x64, IE9 x32. WebAii 2012.2 920.

  2. Stoich
    Stoich avatar
    1 posts

    Posted 09 Oct 2012 Link to this post

    Hello Anton,

    the error message System.NullReferenceException: Object reference not set to an instance of tells us that you're trying to access an object that is simply not there.

    The error was thrown on the following line:


    This line of code can be broken down into two separate lines:

    HtmlSpan a = frame1.Find.ByXpath<HtmlSpan>("/html/body/form/span[2]/div/div/div/span");


    Now we have two options. Either frame1 is actually null (which means the previous line of code fail to find the frame). Or the variable "a" is null which means the Find statement invoked on the frame did not return any elements. 

    The way you're locating the frame and I know it works fine on our end for both IE and FF. So it's unlikely to be that.

    The xPath is not the most reliable way to locate elements. So that's probably the problem. Unfortunately I cannot offer any suggestion for an alternative because I don't actually have access to the content of the frame. You might be wondering why it works in IE and FF but browser differences are a known occurrence:

    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top