0

I'm trying to interact with a webpage through VB using a WebBrowser. When I click a button within my software, I want it to click a button that's located on a webpage.

Using inspect element on the button placed on the website, it shows as a standard div id with style paramenters linked to it. There is also a jQuery event that the div is referencing, showing as the website but with a port number on the end www.example.com:77

The jQuery is as follows

function() {
  try {
    gDvr.Record(false);
  } catch (e) {}
}

All I want to do is inject that statement so it is set to true through my VB application. I so far have this solution but only links to the div id which isn't very useful

WebBrowser1.Navigate("www.example.com/")
For Each Element As HtmlElement In WebBrowser1.Document.GetElementById("LVRcA").InvokeMember("click")
    Exit For
Next Element
S.T
  • 67
  • 7

1 Answers1

0

In the past I used the InvokeScript method for such scenarios.

A robust alternative to the .NET WebBrowser control there is CefSharp which is a full featured, modern web browser control/Chromium Embedded Framework that is compatible with the .Net Framework and the VB.NET language. It provides a wide array of document manipulation. In my opinion, it is a superior alternative to the WebBrowser control that ships with standard Microsoft .Net controls.

I find it superior as it is not as antiquated as the .Net WebBrowser control allowing advanced DOM manipulation, reading and processing of modern html, css and javascript, support for modern video formats etc. Additionally, advanced programming against HTML is a highly supported feature.

Update: On StackOverFlow there is a thread discussing simulating mouse clicks and key presses on the html in CefSharp. VB.NET version and C# (easily translated to VB) sending keystrokes to DOM here

DaveCS
  • 950
  • 1
  • 10
  • 16