vbs 打开指定浏览器网页

新建脚本test.vbs
1.打开谷歌浏览器

Dim wsh
Set wsh = CreateObject("wscript.shell") 
set wshshell=CreateObject("wscript.shell")
wshshell.Run"chrome.exe http://localhost:9527/#/login" '如果浏览器打不开添加绝对路径,后面添加访问的路径
wsh.AppActivate " " ' 引号中填浏览器最上面的标题 
WScript.Sleep 1000*8 
wsh.SendKeys "admin" '引号中填帐号 
WScript.Sleep 1000*4
wsh.SendKeys "{ENTER}"
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*5 
wsh.SendKeys "abcd_1234" '引号中填密码 
WScript.Sleep 1000*3 
wsh.SendKeys "{ENTER}"


Set objShell = CreateObject("Wscript.Shell")
objShell.SendKeys "{F11}"

2.打开ie浏览器

Dim wsh,ie 
Set wsh = CreateObject("wscript.shell") 
Set ie = WScript.CreateObject("InternetExplorer.Application") 
URL=" http://www.baidu.com"
ie.visible = True
ie.navigate URL 
WScript.Sleep 1000*5 
wsh.AppActivate " " ' 引号中填浏览器最上面的标题 
WScript.Sleep 1000*1 
wsh.SendKeys "帐号" '引号中填帐号 
WScript.Sleep 1000*1 
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1 
wsh.SendKeys "密码" '引号中填密码 
WScript.Sleep 1000*1 
wsh.SendKeys "{ENTER}"

Set objShell = CreateObject("Wscript.Shell")
objShell.SendKeys "{F11}"

3.模拟清除缓存登录

Dim wsh
Set wsh = CreateObject("wscript.shell")
set wshshell=CreateObject("wscript.shell")

Url="http://localhost:9527/#/login"


wshshell.Run"""C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe""" & Url
WScript.Sleep 1000*3
wsh.SendKeys "^+{Delete}"
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{ENTER}"
WScript.Sleep 1000*3

wshshell.Run"""C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe""" & Url

WScript.Sleep 1000*4
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1

wsh.SendKeys "{ENTER}"

Set objShell = CreateObject("Wscript.Shell")
objShell.SendKeys "{F11}"

特殊功能键
Shift---------WshShell.SendKeys “+” 常用于转换中英文
Ctrl---------WshShell.SendKeys “^”
Alt---------WshShell.SendKeys “%”
要发送加号“+”,可使用WshShell.SendKeys “{+}”
Space---------WshShell.SendKeys " "
Enter---------WshShell.SendKeys “{ENTER}”
←---------WshShell.SendKeys “{RIGHT}”
↑---------WshShell.SendKeys “{UP}”
F1---------WshShell.SendKeys “{F1}”
BACKSPACE {BACKSPACE}, {BS}, 或 {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or Delete {Delete} 或 {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER}或 ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or Insert {Insert} 或 {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

软件测试日常记录

你的鼓励是我创作最大的鼓励

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值