Instalar el paquete Nuget de GeckoFX https://www.nuget.org/packages/GeckoFX/
o referenciar las dlls Geckofx-Core y Geckofx-Winforms.
En la barra de herramientas, elegir elementos ... seleccionar la dll Geckofx-Winforms.dll
y ya dispondremos de GeckoWebBrowser para añadirlo al diseñador.
Sub New()
InitializeComponent()
Xpcom.Initialize("Firefox")
End
Sub
Private
Sub GeckoWebBrowser1_DocumentCompleted(sender As Object, e As Gecko.Events.GeckoDocumentCompletedEventArgs)
Handles GeckoWebBrowser1.DocumentCompleted
With
GeckoWebBrowser1
'login
If
.Document.GetElementById("idpage").GetAttribute("value") = "login"
Then
'inyectamos
script para validarnos
Dim
script = .Document.CreateElement("script")
script.TextContent = "function logon(){" & _
"document.getElementById('username').value
= 'myuser';" & _
"document.getElementById('password').value
= 'mypassword'" & _
";document.getElementById('login_form').submit();}"
.Document.GetElementsByTagName("head").First().AppendChild(script)
.Navigate("javascript:void(logon())")
End If
End With
End Sub
No hay comentarios:
Publicar un comentario