bzcyer's profileEffective TestingPhotosBlogListsMore Tools Help

Blog


    3/24/2008

    为什么doc一直是null....

      webBrowser1.Navigate("http://www.baidu.com");

              HtmlDocument doc = (HtmlDocument)webBrowser1.Document.DomDocument;

              HtmlElement keyword = (HtmlElement)doc.GetElementById("kw");
              keyword.SetAttribute("kw", "bzcy");
              Thread.Sleep(2000);
              HtmlElement sub = (HtmlElement)doc.GetElementById("sb");
              sub.Click();

      在定义doc时,是从webbrowser1.Document.DomDocument来,但这样doc一直是Null,直接导致后面引用doc来拿  keyword出现错误:未将对象引用设置到对象的实例。

    不明白为什么。。。

    Comments (1)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    bzcyerwrote:
    是因为没有处理多个IE实例。
    Apr. 13

    Trackbacks

    The trackback URL for this entry is:
    http://bzcyer.spaces.live.com/blog/cns!6876CC763CA2DE79!298.trak
    Weblogs that reference this entry
    • None