簡體   English   中英

IHTMLDocument2等到單擊后加載

[英]IHTMLDocument2 wait until loaded after click

我有一種方法,可以根據身份驗證的輸入名稱,它們的值並單擊“登錄”按鈕來自動登錄網站。 登錄后,我想導航到需要身份驗證的頁面。 我已經嘗試過這種實現,如下所示:

private void authenticateWebpage(string username, string userValue, string password, string passwordValue, string submitButton)
    {
        mshtml.IHTMLDocument2 doc = ((mshtml.HTMLDocumentClass)webPage.Document);
        ((mshtml.IHTMLElement)doc.all.item(username)).setAttribute("value", userValue);
        ((mshtml.IHTMLElement)doc.all.item(password)).setAttribute("value", passwordValue);
        ((mshtml.HTMLInputElement)doc.all.item(submitButton)).click();
        doc.url = "http://facebook.com/messages";

    }

我的問題是身份驗證完成之前,URL已設置為轉到"http://facebook.com/messages" 有沒有一種方法可以等到身份驗證完成后才導航到其他URL? 謝謝。

在您的情況下,添加Thread.Sleep(5000)應該可以。 5000以毫秒為單位,因此實際上是5秒。 您可以根據需要增加時間。

謝謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM