WebBrowser Object Control RRS feed

  • Question

  • I have 2 questions.  Both involve the same background conditions, which are:

    I have a project which is successfully using a couple of generic WebBrowser objects (WB1 and WB2).  One of them is running a commercial website and is trouble free, but the other is hosting a developmental webpage running HTML and Java Script in support of Google Map functions.  It is working as well but because it is developmental and I'm changing it a lot, I need the ability to be able to troubleshoot within the WebBrowser object.  If I were using a commercial browser, the F12 function key would provide some limited capability to track variables and troubleshoot the flow of the HTML/Java code.

    Question 1:
    Is there any capability to troubleshoot within a generic Visual Studio/ WebBrowser object?  If so, I would greatly appreciate a push in the right direction.  If not, how do people troubleshoot when using these objects?  Are there any work arounds?

    Question 2:
    Is there any means within the environment to instantiate a URL within a commercial browser (Edge, Firefox, Chrome) in a manner that allows the instantiated object to be addressed and communicated with?  I need the ability to push data into input boxes and read data values from the webpage.  I have been able to launch my webpages with the Process.Start functions but they do not seem to be addressable and I don't know  how to push and pull data from the webpages unless I can address the webpage object.

    Thanks for any help you can provide and Happy New Year!

    Bob Goodwin

    Bob Goodwin

    Thursday, January 3, 2019 5:37 PM

All replies

  • Hello,

    I can reply to question 1 (busy at work). There is no option to mimic developer tools for the Visual Studio web browser control which means no bookmarks to step through code and/or examining elements in the DOM not fiddle with things via jQuery.

    Best thing I can recommend is not even close to dev tools, hookup to capture any errors via the following to subscribe to errors.

    This was code in VS2017, if using an earlier release of VS e.g. below VS2015 you will need in some cases line continuation character e.g. _

    AddHandler WebBrowser1.DocumentCompleted,
    Sub(o, eArgs)
        AddHandler WebBrowser1.Document.Window.Error,
          Sub(w, we)
              we.Handled = True
              ' Do something with the error...
                  $"Error: {we.Description}" + vbLf + $"line: {we.LineNumber}" + vbLf + $"url: {we.Url}") '#2 - #1 - #0
          End Sub
    End Sub

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, January 3, 2019 7:16 PM