|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: |
Public Class boabrowsr1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://mywebsite")
WebBrowser1.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
fill("remote", "Mypassword", "text")
fill("password","myPassword","Password")
Me.submitButton(" Submit")
End Sub
Private Sub fill(ByVal textboxname As String, ByVal text As String, ByVal type As String)
Dim doc2 As mshtml.HTMLWindow2Class = CType(WebBrowser1.Document.Window.DomWindow, mshtml.HTMLWindow2Class)
Dim objDoc2 As mshtml.IHTMLDocument = CType(doc2.document, mshtml.IHTMLDocument)
' Create a collection of all the "input" elements in the page.
Dim wbrAll As mshtml.IHTMLElementCollection = objDoc2.getElementsByTagName("input")
' Create an object that will be a single instance of an input element
Dim wbrElm As mshtml.IHTMLElement
' Create a few variable to hold values from the input element
Dim strName2 As String
Dim strId2 As String
Dim strvalue2 As String
Dim strType2 As String
Try
' Iterate through the collection of html elements, i.e. our input collection
For Each wbrElm In wbrAll
' Assign the inner html values of the input to our variables
strName2 = wbrElm.getAttribute("name")
strId2 = wbrElm.id
strvalue2 = wbrElm.innerText
strType2 = wbrElm.getAttribute("type")
' We are only interested in filling text boxes, and only interested in a specific one, i.e. "q"
If strType2.ToString.ToLower = type And strName2.ToString = textboxname Then
' Set the "value" with the setAttribute method.
wbrElm.setAttribute("value", text)
' Scroll the page so that we can see the input is filled.
'wbrElm.scrollIntoView()
End If
Next
Catch ex As Exception
' ' If there is an error, it is for the reason stated below - you can change the code to be more robust or to handle different pages.
' MessageBox.Show("It is likely that your input does not exist or has no name attribute. Check the HTML source.", "No name att. or no input available", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
Sub submitButton(ByVal txtButtonName As String)
Dim doc As mshtml.HTMLWindow2Class = CType(WebBrowser1.Document.Window.DomWindow, mshtml.HTMLWindow2Class)
Dim objDoc As mshtml.HTMLDocument = CType(doc.document, mshtml.HTMLDocument)
Dim wbrAll As mshtml.IHTMLElementCollection = objDoc.getElementsByTagName("input")
' Create an object that will be a single instance of an input element
Dim wbrElm As mshtml.IHTMLElement
' Create a few variables to hold values from the input element - you can create more
Dim strName As String
Dim strId As String
Dim strValue As String
'Dim strType As String
'Try
' Iterate through the collection of html elements, i.e. our input collection
For Each wbrElm In wbrAll
'MessageBox.Show(wbrElm.getAttribute("id"))
' Assign the inner html values of the input to our variables
strName = wbrElm.getAttribute("id") & ""
strId = wbrElm.id
strValue = wbrElm.innerText
'strType = wbrElm.getAttribute("type")
'MessageBox.Show(strName.ToString, txtButtonName)
' We are only interested in submitting the form right now, so, this time around we'll do the normal submit button
If strName = txtButtonName Then
' Scroll the page so that we can see button that we are clicking - totally not necessary - but makes the user thing something is happening - kind of like lights on early mainframes
'wbrElm.scrollIntoView()
' Create an object to access the DOM and get to the submit button
Dim btnSearch As mshtml.HTMLButtonElement
' Set the created search button equal to the search button on the google page, and set it to the first one (i.e. the one at the top of the page (there are 2), to the index is 0
btnSearch = objDoc.all.item(txtButtonName, 0)
' Click the button
btnSearch.click()
' Remember that there are more elements that you can create, like htmlInputImage. HTMLAnchorElement and many more
End If
Next ' end interation through html oject collection
'Catch ex As Exception
' If there is an error, it is for the reason stated below - you can change the code to be more robust or to handle different pages.
' MessageBox.Show("It is likely that your submit does not exist or has no name attribute. Check the HTML source.", "No name att. or no submit available", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
' End Try
End Sub
End Class
|
Advertisement
| Hall of Fame |