我在从HTML页面获取元素时遇到问题

时间:2016-06-15 06:20:20

标签: vbscript

我所做的是导航到某个网站然后我想找到一个名为“jobId”的元素

Const PAGE_LOADED = 4

Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("http://172.25.25.32:8090/")

objIE.Visible = True

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop

objIE.Document.all.Username.Value = "ashishgi"
objIE.Document.all.Password.Value = "apac2015#"

If Err.Number <> 0 Then
    msgbox "Error: " & err.Description
End If

Call objIE.Document.all.gaia_loginform.submit

Set objIE = Nothing

当我使用ViewSource时,这是我想要使用的元素:

input type="submit" name="btnsubmit" value="Login" id="logincaption" class="button" style="color:#565656"

1 个答案:

答案 0 :(得分:0)

那么,您是否正在尝试点击提交?您的解释很难解释您希望脚本执行的操作。根据您在样本上显示的元素是提交按钮。自从我自动化表单以来已经有一段时间,但我相信你想要这样的效果。

objIE.Document.getElementsById("Username").Value = "ashishgi"
objIE.Document.getElementsById("Password").Value = "apac2015#"
' If you want to use the button by name
objIE.Document.all.item("btnsubmit").click
' If you want to use the button by ID
objIE.Document.getElementsById("logincaption").click

'if that fails, make it an object like this and action the click.
Set Submit = objIE.Document.getElementsById("logincaption")
submit.click