2016-10-13 34 views
0

由于无法预料的数据涌入,我现在有一个需要完成的webforms超载。打开带有多个ID的ID,选择值并提交

我们需要的:打开IE浏览器并导航到一个变量URL

  • 的VBScript。
  • 如果弹出窗口出现(仅出现在某些URL上),请单击确定。
  • 等待网页加载–网址加载速度很快,但JavaScript网页速度较慢。
  • 从下拉框中进行选择。
  • 从下拉框中再次选择。
  • 点击提交。

表单完成后,它需要转到“下一个URL”并执行相同的任务。

现在正如我在本文开头所提到的,每个表单的URL都不相同。然而,它只是URL的最后部分而异。看下面的例子。只有ID发生变化,URL才会保持不变。

http://saves/GEM/wwwsci/cms_call_outcome_sts_frame.html?id=TCAWSNG19924556

我有一个包含数百个id的列表,都需要更新。

正如前面提到的,我已经预先填充了过去的表单,但没有必要引用列表。

这里的相似,我已经在过去用过的东西:

Dim URL 
Dim IE 

Set objIE = CreateObject("InternetExplorer.Application") 

Call objIE.Navigate("http://saves/GEM/wwwsci/cms_call_outcome_sts_frame.html?id=TCAWSNG19924556") '<-- Don't know how insert id referenced from a list. 

objIE.Visible = True 

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop '<-- load url 
WScript.Sleep(25000) '<-- Wait for webpage JavaScript (can take 20 seconds) 

'Need to press "Enter" here if a pop up occurs - Maybe .SendKeys? 

IE.Document.getElementByName("oper_select10").value = "1" 'select first drop down box (not working) 
IE.Document.getElementByName("oper_select6").value = "1" 'select second drop down box (not working) 
IE.Document.getElementByName("I2").Click 'Submit form (not working) 

WScript.Sleep(2500) 

然后脚本需要循环但使用不同的ID。

我也很好奇,为什么即使选择我的下拉框的基础知识不起作用。

回答

0

你可以调用不同的ID的URL在这样的循环:

'read IDs from file into array 
Set fso = CreateObject("Scripting.FileSystemObject") 
idList = Split(fso.OpenTextFile("C:\path\to\input.txt").ReadAll, vbNewLine) 

Set objIE = CreateObject("InternetExplorer.Application") 
For Each id In idList 
    objIE.Navigate "http://saves/GEM/wwwsci/cms_call_outcome_sts_frame.html?id=" & id 
    'rest of your code goes here 
Next 

不能帮助你与你的代码的其余部分没有实际看到你想要的页面的HTML和JavaScript代码处理。

+0

@Randazd不客气。如果您发现它解决了您的问题,请考虑[接受答案](http://meta.stackoverflow.com/a/5235)。 –