Internet explorer 如何在VBScript中获取没有ID的元素
我正试图编写一个脚本来驱动我的IExplorer。它在某种程度上可以正常工作,但我需要在Internet explorer 如何在VBScript中获取没有ID的元素,internet-explorer,vbscript,Internet Explorer,Vbscript,我正试图编写一个脚本来驱动我的IExplorer。它在某种程度上可以正常工作,但我需要在文本区域中输入一个值,然后在它们都没有ID的情况下单击一个按钮。我不知道如何使用VBScript在HTML DOM中四处移动,但有人建议在某个地方使用文档。所有的。我还考虑使用JS脚本为他们提供ID,然后返回并使用document.getElementbyid,但我不知道如何在VBScript中运行JS脚本,同时考虑初始化的document对象。到目前为止,我得到的是: Option Explicit Wit
文本区域中输入一个值,然后在它们都没有ID的情况下单击一个按钮。我不知道如何使用VBScript在HTML DOM中四处移动,但有人建议在某个地方使用文档。所有的。我还考虑使用JS脚本为他们提供ID,然后返回并使用document.getElementbyid
,但我不知道如何在VBScript中运行JS脚本,同时考虑初始化的document对象。到目前为止,我得到的是:
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
另外,因为我要填补的领域是
<textarea style="overflow-y: hidden; height: 36px;" class="sB5 sPEB"></textarea>
并且它没有值属性,它的值是如何输入的?使用诸如hasChildNodes
和nextNode
来移动,或者selectSingleNode
和selectNodes
来直接访问。文本值存储为中textarea
元素的子元素
参考资料
使用诸如hasChildNodes
和nextNode
等移动,或selectSingleNode
和selectNodes
直接访问。文本值存储为中textarea
元素的子元素
参考资料
而不是使用.Document.All.tags(“sB5 sPEB”).Value=“southpark”
试试下面的代码
检查类是否唯一
.Document.getElementsByClassName("sB5 sPEB").Value = "southpark"
否则,使用for循环和with if语句发送值,而不是使用.Document.All.tags(“sB5 sPEB”).value=“southpark”
试试下面的代码
检查类是否唯一
.Document.getElementsByClassName("sB5 sPEB").Value = "southpark"
否则,使用for循环和if语句发送值您可能正在使用IE 8或以前的版本。IE DOM不支持GetElementsByCassName()。请检查此quirksmode.org/dom/w3c_core.htmlYou可能正在使用IE 8或以前的版本。IE DOM不支持GetElementsByCassName()。请检查此quirksmode.org/dom/w3c_core.html