I'm using VB.net to fill out internet explorer forms. After the form is filled out I have to click on the "Search" button.
When I try to click a button with no ID I loop through all the HTML elements after i've navigated to the correct page and filled out the form. I try saying if the onclick is correct then element.click, if the value is correct the element.click, if the innerhtml is correct then element.click and nothing will work.
What can I change so my code will click this button?
Code:
<td align="left" width="113px">
<input type="button" value="Search" onclick="GetPTypeSak(); Button_Click();" />
</td>
When I try to click a button with no ID I loop through all the HTML elements after i've navigated to the correct page and filled out the form. I try saying if the onclick is correct then element.click, if the value is correct the element.click, if the innerhtml is correct then element.click and nothing will work.
Code:
Dim IE As Object = CreateObject("internetexplorer.application")
Dim element As mshtml.IHTMLElement
for each element in IE.document.all
If element.innerHTML.Contains("GetPTypeSak(); Button_Click();") Then
'this didn't work i got a nullreferenceexception object reference not set to an instance of an object
'if element.getattribute("value") = "Search"
'didn't work I got an invalidcastexception operator '=' is not defined for type 'DBNull'
'if element.getattribute("onclick")= "GetPTypeSak(); Button_Click();"
'didn't work I got an invalidcastexception operator '=' is not defined for type 'DBNull'
'If element.onclick = "GetPTypeSak(); Button_Click();" Then
'Operator '=' is not defined for type 'DBNull' and string "GetPTypeSak(); Button_Click();"
element.click()
End If
What can I change so my code will click this button?