博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

一些常用代码

Posted on 2009-03-24 16:46  Testing of S小调  阅读(128)  评论(0)    收藏  举报

1.1.    用代码来启动浏览器

方法1.  Browser1 = "IE"
  StartURL = "www.51testing.com"
  IF Browser1 = "IE" THEN
     set IE = CreateObject("InternetExplorer.Application")
     IE.Visible = true
­
     IE.Navigate StartURL


方法2.

  SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe",www.163.com

方法3.

  SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe"

  Browser("title:=about:blank").Sync

Browser("title:=about:blank").Navigate www.tom.com

 

1.2.    change sysdate

Dim oShell

Set oShell = CreateObject ("WSCript.shell")

oShell.run "cmd /K date 07-10-03"

Set oShell = Nothing

systemutil.CloseProcessByName("cmd.exe")

msgbox(date)    输出是7/10/2003

 

1.3.    模拟键盘操作

Set shell=Createobject("WScript.Shell")

shell.sendkeys  "CAPSLOCK"    点击capslock

具体键位请参照QTP帮助,关键字:sendkeys