Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

VBScript for Web Automation. Only have Element Names

$
0
0

Have been looking to solve this (test from my boss) for 2 days now.

I have a webpage that is all Javascript that we are trying to automate with a VBScript (yes it needs to be in VBScript)

This issue that I am running into is that the fields I need to populate of select from a combo box do not have ID's and the only unique element is the name.  For another web page that I am automating I am using the .getElementsByID function.   However when I try to use the .getElementsByName I receive WSH error "Object support this property or method:...."

What I am trying to do is select an item from the drop down in HTML Snip1 below and then hard code in a value to enter in the textbox for HTML Snip2 below.  

Any help would be greatly appreciated.

 

VBScript


'Sub for Page Load Time Wait
Sub IEPageLoad(obj)
Do while IE.busy
WScript.Sleep 100
Loop
End Sub

set ie = WScript.CreateObject("InternetExplorer.Application")
    ie.navigate("https://www.thisisthewebpage")
    ie.visible = True

IEPageLoad(IE)

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.SendKeys "UserID"
WScript.Sleep 100
objShell.SendKeys "{TAB}"
WScript.Sleep 100
objShell.SendKeys "Password"
WScript.Sleep 100
objShell.SendKeys "{Enter}"

IEPageLoad(IE)

With ie.Document
    .getElementsByName("searchBy").Select = "User ID"
End with

HTMLSnip1

<tr>
<tdclass ="field">
<selectname ="searchBy"class ="field"onchange = "restrictLength()">
<optionvalue ="Username">
User ID
</option>
'and 13 other options in the dropdown the same way

HTML Snip 2

<formname ="searchValueForm"method ="post"onSubmit ="handleFunction('Search'); return false;">
<td>
<inputtype ="text"name ="searchValue"size ="20"class ="field"value ="" />
</td>
</form>


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>