vb.net cefsharp.windows document.getElementById

1,320 views
Skip to first unread message

Hans Ronken

unread,
Jun 14, 2021, 5:58:52 AM6/14/21
to CefSharp

We used webbrowser control to login website in VB.NET, now we are going to us CefSharp. We have made a simple test form. Clicking on the button sets the "toegangscode" with xxxxxx. It works, but when I go to next field wachtwoord (password) and type 1 first character the "toegangscode" field will be made empty. What I am doing wrong ?


Public Class Form1


Public WithEvents browser As ChromiumWebBrowser


Public Sub New()

    ' This call is required by the designer.

    InitializeComponent()

    Dim settings As New CefSharp.WinForms.CefSettings()

    CefSharp.Cef.Initialize(settings)


    browser = New CefSharp.WinForms.ChromiumWebBrowser("https://diensten.kvk.nl/inloggen.html") With {

        .Dock = DockStyle.Fill}

    Panel1.Controls.Add(browser)


End Sub


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


    Dim jsScript1 = <js><![CDATA[document.getElementById("username").Focus();]]></js>.Value

    browser.ExecuteScriptAsync(jsScript1)



    Dim jsScript2 As String = <js><![CDATA[document.getElementById("username").value = "xxxxxx";]]></js>.Value

    browser.ExecuteScriptAsync(jsScript2)

End Sub

End Class

Reply all
Reply to author
Forward
0 new messages