VB NET Trying to load page on WebBrowser

  • Thread starter Thread starter ImKookiE
  • Start date Start date
I

ImKookiE

Guest
Hello,

i am trying to load a aspx page on a webbrowser but it can't display the page.,

The URL is myprio.com

If i get the URL from the webbrowser it says the right one, but no page is displayed.

If i load google.com, the page is displayed without any problem

My goal is to fill some fields and then click the button to submit them(the page that i am trying to field is after the login, you can find the code of the button bellow).


my code:

wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_Name").SetAttribute("value", sheet.Range("B" & i).Value.ToString)
wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_Street").SetAttribute("value", ".")
wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_PostalCode").SetAttribute("value", "0000-000")
wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_City").SetAttribute("value", sheet.Range("D" & i).Value.ToString)
wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_CCBI").SetAttribute("value", ".")
wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_NIF").SetAttribute("value", sheet.Range("A" & i).Value.ToString)
wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_Phone").SetAttribute("value", "910000000")
Dim element2 As HtmlElement = wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_TypeBottleId")
If element2 IsNot Nothing Then
Dim value As Integer = CInt(Int((2 * Rnd()) + 1))
Dim artigo As String = ""
If value = 1 Then
artigo = "G110 - PROPANO 45 kg"
ElseIf value = 2 Then
artigo = "G22 - PROPANO 9 kg"

End If
Dim TheCombo =
(
From X In wb.Document _
.GetElementsByTagName("select").Cast(Of HtmlElement)()
Where X.GetAttribute("ID") = "DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_TypeBottleId"
Select X.GetElementsByTagName("option")
).FirstOrDefault

Dim ItemToSelect =
(
From X In TheCombo.Cast(Of HtmlElement)()
Where X.InnerText = artigo
).FirstOrDefault

ItemToSelect.SetAttribute("selected", CStr(True))
Console.WriteLine("cOMBO: " & wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_TypeBottleId").GetAttribute("value").ToString)

Else
MsgBox("Nao existe")
End If

wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_PurchaseDate").SetAttribute("value", Today.ToString("yyyy-MM-dd"))
wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtBail_Number").SetAttribute("value", sheet.Range("C" & i).Value.ToString)
wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtValueBailConfigWB_wtListRecords1_ctl00_wt1").InvokeMember("click")
Console.WriteLine("Radio: " & wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtValueBailConfigWB_wtListRecords1_ctl00_wt1").GetAttribute("value"))
'wb.Document.GetElementById("DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtButtonSave").InvokeMember("submit")
'id of the button DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtButtonSave
Dim myHtmlElement As HtmlElement
For Each myHtmlElement In wb.Document.All

If myHtmlElement.GetAttribute("value") = "Registar Caução" AndAlso myHtmlElement.GetAttribute("type") = "submit" Then


myHtmlElement.Focus()
SendKeys.Send("{ENTER}")


End If
Next

html code of the button:

<input onclick="if (OsPage_ClientValidate('DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtButtonSave')) OsAjax(arguments[0] || window.event,'DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtButtonSave','DublinTheme_wt19$block$wtMainContent$wtRegisterBailWB$wtButtonSave','','__OSVSTATE,',''); return false;" type="submit" name="DublinTheme_wt19$block$wtMainContent$wtRegisterBailWB$wtButtonSave" value="Registar Caução" id="DublinTheme_wt19_block_wtMainContent_wtRegisterBailWB_wtButtonSave" tabindex="42" class="Button Is_Default ThemeGrid_MarginGutter">

My webbrowser after loading the page

1283178.png


I'm with this problem at like 4 days.. can't solve it.

Any suggestions?

If you need any more information please ask

Thanks!



Continue reading...
 
Back
Top