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", "kimyong95@gmail.com");
}

This is my program which navigate to "https://console.api.ai/api-client/#/login".

I trying to fill "kimyong95@gmail.com" into the Email textbox in the website using .SetAttribute but it doesn't work.

Anyone know how to solved this?

Thanks!

Daniel
  • 9,491
  • 12
  • 50
  • 66

1 Answers1

0

In the provided sample code you are trying to modify element property via the element attribute. Element attributes cannot be used to modify element properties: What is the difference between properties and attributes in HTML?

Here is a sample code that demonstrates how to use the Value property for setting the input field value:

DOMInputElement username = (DOMInputElement)document.GetElementById("username");
username.Value = "kimyong95@gmail.com";

The sample by the following link demonstrates how to work with various form fields: https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000110038-setting-input-field-value-working-with-form

Anna Dolbina
  • 1
  • 1
  • 8
  • 9