I am trying to write a script to drive my IExplorer. It works okay up to a point but then I need to enter a value in a textarea
and click a button while they both have no ID. I have no idea how I can move arround in the HTML DOM using VBScript but it was suggested somewhere to use document.all
somehow. I was also thinking of maybe using a JS script to give them IDs and then go back and use document.getElementbyid
but I don't know how to run a JS script from within the VBScript with the initialised document object in mind. What I have so far is:
Option Explicit
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "https://adwords.google.co.uk/um/Logout"
Do While .Busy
WScript.Sleep 100
Loop
.Document.getElementByID("Email").Value = "testtestingtton@gmail.com"
.Document.getElementByID("Passwd").Value = "PWD"
'Note: You could just get the form and submit it, but
'you'll miss out on any special JavaScript associated
'with the Submit button.
.Document.getElementByID("signIn").Click
Do While .Busy
WScript.Sleep 100
Loop
.Navigate "https://adwords.google.co.uk/o/Targeting/Explorer?"
Do While .Busy
WScript.Sleep 100
Loop
'here begins the problem'
.Document.All.tags("sB5 sPEB").Value = "southpark"
'.Document.getElementsByTagName("sJ1").Click'
End With
Also since the field I am trying to fill is
<textarea style="overflow-y: hidden; height: 36px;" class="sB5 sPEB"></textarea>
and it has no value attribute how is its value inputed?
Best Answer
Use MSXML DOM methods such as
hasChildNodes
andnextNode
to move around, orselectSingleNode
andselectNodes
for direct access. The text value is stored as a child of thetextarea
element in a text node.References
How to Create a Dynamic Email Signature
How to automate the deletion of backups in SharePoint Server 2007 and in Windows SharePoint Services 3.0 by using a Visual Basic script
Use XPath to Perform a Case-Insensitive Search with MSXML
How To Use XPath Queries in MSXML DOM selectNodes Method
Using the right version of MSXML in Internet Explorer