Is it possible in VB.NET GeckoFX to use 'GetelementByID'?

-1

Is it possible in VB.NET GeckoFX to use GetelementByID ? I made a few attempts with the code using google.com:

geckowebbrowser1.document.getelementbyid("lst-ib").setattribute("value", "teste")

but it is returning me: "Object reference not set to an instance of an object." Gecko.GeckoDomDocument.GetelementByID (...) returned Nothing

I've been searching for a few days and have not found it.

    
asked by anonymous 18.08.2017 / 13:20

1 answer

0

Unlike WebBrowser , this is another procedure for getting the ID of an HTML element. Consider this little code your page and its element:

<div id="lst-ib">conteúdo</div>

In the Gecko API, you need to create an instance of a GeckoHtmlElement , so it will not cause null references, as in your error.

Dim elemento As GeckoHtmlElement
ele = geckowebbrowser1.Document.GetHtmlElementById("lst-ib")
If(ele Is Nothing) MsgBox("Não foi possível encontrar um elemento com esse ID.")
ele.setAttribute("value", "teste")

setAttribute documentation (string, string)

Response font

    
18.08.2017 / 21:09