Search code examples
c#visual-studio-2010webbrowser-controlhtml-frames

Webbrowser control is not showing Html but shows webpage


I am automating a task using webbrowser control , the site display pages using frames. My issue is i get to a point , where i can see the webpage loaded properly on the webbrowser control ,but when it gets into the code and i see the html i see nothing.

I have seen other examples here too , but all of those do no return all the browser html.

What i get by using this:

                    HtmlWindow frame = webBrowser1.Document.Window.Frames[1];
                    string str = frame.Document.Body.OuterHtml;

Is just :

The main frame tag with attributes like SRC tag etc, is there any way how to handle this?Because as i can see the webpage completely loaded why do i not see the html?AS when i do that on the internet explorer i do see the pages source once loaded why not here?

ADDITIONAL INFO

There are two frames on the page :

i use this to as above:

HtmlWindow frame = webBrowser1.Document.Window.Frames[0];

        string str = frame.Document.Body.OuterHtml;

And i get the correct HTMl for the first frame but for the second one i only see:

<FRAMESET frameSpacing=1 border=1 borderColor=#ffffff frameBorder=0 rows=29,*><FRAME title="Edit Search" marginHeight=0 src="http://web2.westlaw.com/result/dctopnavigation.aspx?rs=WLW12.01&amp;ss=CXT&amp;cnt=DOC&amp;fcl=True&amp;cfid=1&amp;method=TNC&amp;service=Search&amp;fn=_top&amp;sskey=CLID_SSSA49266105122&amp;db=AK-CS&amp;fmqv=s&amp;srch=TRUE&amp;origin=Search&amp;vr=2.0&amp;cxt=RL&amp;rlt=CLID_QRYRLT803076105122&amp;query=%22LAND+USE%22&amp;mt=Westlaw&amp;rlti=1&amp;n=1&amp;rp=%2fsearch%2fdefault.wl&amp;rltdb=CLID_DB72585895122&amp;eq=search&amp;scxt=WL&amp;sv=Split" frameBorder=0 name=TopNav marginWidth=0 scrolling=no><FRAME title="Main Document" marginHeight=0 src="http://web2.westlaw.com/result/dccontent.aspx?rs=WLW12.01&amp;ss=CXT&amp;cnt=DOC&amp;fcl=True&amp;cfid=1&amp;method=TNC&amp;service=Search&amp;fn=_top&amp;sskey=CLID_SSSA49266105122&amp;db=AK-CS&amp;fmqv=s&amp;srch=TRUE&amp;origin=Search&amp;vr=2.0&amp;cxt=RL&amp;rlt=CLID_QRYRLT803076105122&amp;query=%22LAND+USE%22&amp;mt=Westlaw&amp;rlti=1&amp;n=1&amp;rp=%2fsearch%2fdefault.wl&amp;rltdb=CLID_DB72585895122&amp;eq=search&amp;scxt=WL&amp;sv=Split" frameBorder=0 borderColor=#ffffff name=content marginWidth=0><NOFRAMES></NOFRAMES></FRAMESET>

UPDATE

The two url of the frames are as follows :

Frame1 whose html i see

http://web2.westlaw.com/nav/NavBar.aspx?RS=WLW12.01&VR=2.0&SV=Split&FN=_top&MT=Westlaw&MST=

Frame2 whose html i do not see:

http://web2.westlaw.com/result/result.aspx?RP=/Search/default.wl&action=Search&CFID=1&DB=AK%2DCS&EQ=search&fmqv=s&Method=TNC&origin=Search&Query=%22LAND+USE%22&RLT=CLID%5FQRYRLT302424536122&RLTDB=CLID%5FDB6558157526122&Service=Search&SRCH=TRUE&SSKey=CLID%5FSSSA648523536122&RS=WLW12.01&VR=2.0&SV=Split&FN=_top&MT=Westlaw&MST=

And the properties of the second frame whose html i do not get are in the picture below:

enter image description here

Thank you


Solution

  • I paid for the solution of the question above and it works 100 %.

    What i did was use this function below and it returned me the count to the tag i was seeking which i could not find :S.. Use this to call the function listed below:

    FillFrame(webBrowser1.Document.Window.Frames);
    
    
    
    private void FillFrame(HtmlWindowCollection hwc)
            {
    
    
                if (hwc == null) return;
                foreach (HtmlWindow hw in hwc)
                {
                    HtmlElement getSpanid = hw.Document.GetElementById("mDisplayCiteList_ctl00_mResultCountLabel");
                    if (getSpanid != null)
                    {
    
                        doccount = getSpanid.InnerText.Replace("Documents", "").Replace("Document", "").Trim();
    
                        break;
                    }
    
                    if (hw.Frames.Count > 0) FillFrame(hw.Frames);
                }
    
    
            }
    

    Hope it helps people .

    Thank you