chrome console works but javascript from application doesn't

25 views
Skip to first unread message

james johnson

unread,
Jun 6, 2019, 7:13:33 PM6/6/19
to CefSharp
I am trying to use javascript to fill in input boxes with user and pw but I cannot get the commands to work in my application.  I can open chrome and run the same commands from the console and they work.  My code is below:


        Dim oBrowser As WinForms.ChromiumWebBrowser = CType(sender, WinForms.ChromiumWebBrowser)

        If Not oBrowser.IsLoading And docready = True Then
            oBrowser.SetZoomLevel(-0.7)
            oBrowser.ExecuteScriptAsync("document.getElementsByName('userName').item(0).value = " & """" & "test" & """")
        End If


If I run this command in my chrome console it works fine.

document.getElementsByName('userName').item(0).value = "test"

I can do other javascript commands like creating an alert but it seems not all of my functions are working like they should.  I have tried to simply select() the element, then focus(), nothing seems to respond.  Is there something that needs to be declared to make this work?

Kinda lost here.  could use some help.

james johnson

unread,
Jun 7, 2019, 12:36:56 PM6/7/19
to CefSharp
I was able to get it to work by stringing the commands together.  for some weird reason it is filling the fields but there is something going on that is causing it to mess up the characters.  The look right but I have to backspace over the last character and re-enter it to get it to work.  that is strange.  still working on it.
Reply all
Reply to author
Forward
0 new messages