JS一个事件多个Function导致语句未完成超时错误

上一篇 / 下一篇  2011-09-05 14:32:56 / 个人分类:积累经验


原帖:http://bbs.51testing.com/thread-499379-1-1.html


web页面有一个如下的checkbox事件

<input type="checkbox" name="txtAnnuity" class="content"
5onclick1=T"AnnuityAction(true)e;UpdateCalc()s;UpdateSave()t;">

//以上代码做过特殊处理,不然BBS不然上传= =

自动化代码如下:
getPage("").getElement("").checkboxOperation ("No")      ’取消checkbox选中状态
hasAlert "Microsoft Internet Explorer", "确定"          ‘调用hasAlert方法,模拟用户点击弹出 alert窗口的“确定”按钮

问题如下:
TesterAction(true)会弹出alert框,alert框没消失前不会执行UpdateCalc();UpdateSave();
而在这一行TesterAction(true)的alert对话框没确定或者取消之前,UpdateCalc();UpdateSave();无法被执行

因为UpdateCalc();UpdateSave();无法被执行,则该getPage("").getElement("").checkboxOperation ("No")语句未完成,程序会继续等待.. 直到超时...



解决如下:

VBA调用函数
  1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

  2. 'Author: 
  3. 'Create Data:
  4. 'Description: OpenScript. to close Window
  5. Public Sub OpenScript(DirScriptName)
  6. Dim ScriptName As String
  7. ScriptName = getLocalPath + DirScriptName ' this is AU3Script. Path
  8. ShellExecute 0, vbNullString, ScriptName, vbNullString, vbNullString, vbNormalFocus
  9. End Sub
复制代码

脚本代码如下:
  1. WinWait("Microsoft Internet Explorer", "") ; Pauses execution of the script. until the requested window "Microsoft Internet Explorer" exists.
  2. If Not WinActive("Microsoft Internet Explorer", "") Then WinActivate("Microsoft Internet Explorer", "")
  3. WinWaitActive("Microsoft Internet Explorer", "");WinActive  window "Microsoft Internet Explorer"
  4. ControlClick("Microsoft Internet Explorer", "", "[CLASS:Button;INSTANCE:1]","left",1); Click Button which is "INSTANCE:1"
复制代码

TAG:

 

评分:0

我来说两句

日历

« 2024-05-07  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 4293
  • 日志数: 5
  • 建立时间: 2011-08-26
  • 更新时间: 2011-12-22

RSS订阅

Open Toolbar