ie 无人操作自动关闭_VBS+DOM实现IE自动化操作

xmJ!q2?(T3X0

s y6sQ"[3r/k\0

DOM介绍51Testing软件测试网Ey4hcq&m1Fy3c&t.F _

常用对象51Testing软件测试网_:Q(f Kc9u PW#Di

document对象:文档中所有对象51Testing软件测试网zO_&r%q?Y

Body对象:文档中body部分的对象51Testing软件测试网.tD0DuV?3A`

查找对象常用的方法:f[%R:S9ub0

getElementbyid() 返回对象拥有指定id的第一个对象html标记的id属性51Testing软件测试网2WN$`)]/uB_$hi

getElementsbyName() 返回带有指定名称的对象的集合name属性51Testing软件测试网,|1tj1D0_5y

getElementsbyTagName() 返回带有指定标签名的对象的集合html标记51Testing软件测试网/e/Z$T_N

也可以用集合来查找对象`1E;c(y

}.t6C0

如options代表下拉框元素的集合51Testing软件测试网i ihz^Io

elements代表表单中所有的元素51Testing软件测试网mP;qO#B

如访问某个下拉框的选项{2Fy.R?X'J}0

set sel=ie.document.getelementbyid("**").options51Testing软件测试网K$J(c4{.umrc{

for each opt in seld%z&y+P.v!OG0

if opt.text="*" then#O]/q&W2G_fM"x/h*O%x0

opt.selected=truef.Y)X,}L6U0

end if+g&}h\B'c't0

next"hxt%lL/zuXo0

-zq

b6G'm1b0

有的下拉框每个选项是有optionid的,可以这样访问51Testing软件测试网6z+o-{mk8A uK

ie.document.getelementbyid("**").selected=true"s"_KKS,CMM0

1Bx

?cF

g YN*r0

一个例子,访问某网页,检查密码为空的提示是否正确51Testing软件测试网Y-Kr;N]x

DIM URL=""51Testing软件测试网{0Z$C_n|w(V&r

set ie=createobject("internetexplorer.application")51Testing软件测试网`eJ2~C [L

ie.visiable=true51Testing软件测试网4Yo1f'xj!k7wo:d&T]

ie.navigate URL'My~;K;j-n"J0

wscript.sleep 200051Testing软件测试网 KnA+X@;}'k+h

ie.document.getelementsbytagname("input")(1).value="usename"nC T/jF0

ie.document.getelementsbytagname("input")(2).value=""_CYu9d0h}9~0

ie.document.getelementsbytagname("button")(0).clickd,`So2P0

wscript.sleep 200051Testing软件测试网^$pu8[X

j[:i

if ie.document.getelementsbyid("errordiv").innertext="密码不能为空" thenmsgbox“提示正确”51Testing软件测试网GH4b#x^

X%PJsY'Ks0

else|Wl!OC-UMZ

my M0

……4z8a0Yv

qP0

end if51Testing软件测试网QvNXn2FMvI

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值