I'm navigating to a website using
WebBrowser object in C# and i want to get a Html Element that exist in that website but that element is in a deep ugly stack of other elements in fact the address is :
html -> frameset -> frame#mainFrame -> html -> body -> div -> table#AutoNumber -> tbody -> tr -> td -> div -> form#lglform -> table -> tbody -> tr -> td -> table -> tbody -> tr -> td -> input#Button1
when i try to use
GetElementsByTagName("input") i realize i have to first get to parent of that first and for that i have to get to parent of that as well and so on.
is there any way to define a single
HtmlElement and set it to that element directly without getting through all parents?
I'm getting null as a result of GetElementById because
WebBrowser doesn't load website correctly even though I'm using
DocumentCompleted event to making sure of that here is what website looks like in ie inspector:
but WebBrowser Object just load this HTML
is there any way to make
WebBrowser Object to collect all HTML code?
or is there any another good way to approach my goal?
Since your input has an ID of
GetElementById. Failing that though, you'd have to query
webBrowser.Document.All, which is a collection of all the elements in the HTML document.
HtmlElement input = webBrowser1.Document.GetElementById("Button1");