我奋力设置在网页上(一说我不控制)一些很尴尬的字段的值,会看重博芬的输入,请。 我已经做了网页的模拟,展现出该问题。 开始:
<html>
<body>
<div id="mydiv1" style="position: none; display: block; z-index: 1; width: 800px;">
<p>First div (mydiv1) starts here.</p>
<br />
<div id="mydiv2" style="position: none; display: block; z-index: 6; width: 800px;">
<p>Second div (mydiv2) starts here. The following field in blue is arranged thusly: <i>div>div>table>form>table</i>; and its tabIndex is 1.</p>
<table border="0" cellspacing="1" cellpadding="0" width="410">
<tbody>
<tr>
<td colspan="3" style="width: 410px; background-color: #5698eb;">
<form id="entryform" name="entryform">
<table border="0" cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td width="100" valign="center" class=text1">
<br /><b>Project: </b>
</td>
<td width="5"></td>
<td valign="centre">
<input class="formclass_input1" type="text" tabIndex="1" name="entryform_field">
</td>
</tr>
</tbody>
</table>
</form>
</td>
</tr>
</tbody>
</table>
<br />
<div id="mydiv3" style="position: none; display: block; z-index: 16; width: 850px;">
<p>Third div (mydiv3) starts here. The following fields are arranged thusly: <i>div>div>div>form>table</i> and the tabIndexes go 1,2,3,4.<br />The field names change randomly from record to record, but their tabIndexes are always the same.</p>
<form id="myform" name="myform">
<table border="0" cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td width="100" valign="center" class=text1">
<b>Name: </b>
</td>
<td width="5"></td>
<td valign="centre">
<input class="formclass_input1" type="text" tabIndex="1" name="changeable_field_name1">
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td width="100" valign="center" class=text1">
<b>Date: </b>
</td>
<td width="5"></td>
<td valign="centre">
<input class="formclass_input1" type="text" tabIndex="2" name="changeable_field_name2">
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td width="100" valign="center" class=text1">
<b>Company: </b>
</td>
<td width="5"></td>
<td valign="centre">
<input class="formclass_input1" type="text" tabIndex="3" name="changeable_field_name3">
</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="1" cellpadding="0">
<tbody>
<tr>
<td width="100" valign="center" class=text1">
<b>Address: </b>
</td>
<td width="5"></td>
<td valign="centre">
<input class="formclass_input1" type="text" tabIndex="4" name="changeable_field_name4">
</td>
</tr>
</tbody>
</table>
</form>
</div></div></div>
</body>
</html>
这里的关键就是字段名称的变化,随机。 我已经previosuly提出了关于堆栈我的问题,但我过于简单的问题! 名为Panayot一位同行的帮助和解决了这个问题对我来说很好,但是当我介绍我的修订后的脚本对活动网站,它失败了。 从而使这种更准确的实物模型。 这是更复杂,比我第一次提出。 使用Panayot的代码,我的剧本目前看起来是这样的:
surl ="http://[website.com]"
set ie = nothing
set shapp=createobject("shell.application")
on error resume next
For Each owin In shapp.Windows
if left(owin.document.location.href,len(surl))=surl then
if err.number = 0 then
set ie = owin
end if
end if
err.clear
Next
on error goto 0
if ie is nothing then
wscript.echo "Window Not Open"
else
Set myDiv = IE.Document.All.mydiv3
If Not myDiv Is Nothing Then
Set nodes = myDiv.childNodes
For i = 0 To nodes.Length-1 Step 2
If nodes(i).tabIndex = "1" Then
nodes(i).Value = "ta-da!"
'nodes(i).Value = nodes(i).tabIndex
Exit For
End If
Next
End If
End If
我已经尝试了很多与它,但我不能用我有限的了解看着办吧。 基本上最后的IF语句是不是让我进的tabIndex“1”。 如果这是可以解决的,我会成为一个很幸福的人。 任何输入被理解。 谢谢。