2016-11-11 21 views
2
public MainWindow() 
{ 
    InitializeComponent(); 

    BrowserView webView = new WPFBrowserView(); 
    mainLayout.Children.Add((UIElement)webView.GetComponent()); 
    ManualResetEvent waitEvent = new ManualResetEvent(false); 
    webView.Browser.FinishLoadingFrameEvent += delegate (object sender, FinishLoadingEventArgs e) 
    { 
     if (e.IsMainFrame) 
     { 
      waitEvent.Set(); 
     } 
    }; 
    webView.Browser.LoadURL("https://console.api.ai/api-client/#/login"); 
    waitEvent.WaitOne(); 
    DOMDocument document = webView.Browser.GetDocument(); 
    DOMElement username = document.GetElementById("username"); 
    username.SetAttribute("value", "[email protected]"); 
} 

これは、 "https://console.api.ai/api-client/#/login"にナビゲートする私のプログラムです。DotNetBrowserを使用してユーザー名とパスワードを入力する方法

.SetAttributeを使用してウェブサイトのEmailテキストボックスに "[email protected]"を入力しようとしましたが、動作しません。

誰でもこれを解決する方法を知っていますか?

ありがとうございます!

答えて

0

提供されているサンプルコードでは、element属性を使用して要素プロパティを変更しようとしています。要素は、要素のプロパティを変更するために使用することはできません属性:ここではWhat is the difference between properties and attributes in HTML?

は、入力フィールドの値を設定するためのValueプロパティを使用する方法を示すサンプルコードです:

DOMInputElement username = (DOMInputElement)document.GetElementById("username"); 
username.Value = "[email protected]"; 

次のリンクにより、サンプルは方法を示していますさまざまなフォームフィールドで作業する: https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000110038-setting-input-field-value-working-with-form

関連する問題