如何应对使用watir-webdriver控制Firefox的“无响应脚本”弹出窗口

时间:2012-01-25 13:00:40

标签: firefox selenium popup watir-webdriver

这个弹出窗口会杀死我的许多测试。即使是像.exists这样简单的DOM交互?超时。有没有办法检测它出现并解雇它?

Warning: Unresponsive script.

A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.
  

dom.max_script_run_time = 999

     

dom.max_chrome_script_run_time = 19

这些网站不是我设计的,也不受我影响。我只是在抓客户并向他们发送指示。

1 个答案:

答案 0 :(得分:1)

我运行了一个杀死弹出窗口的小型autoit3应用程序。如果我没记错的话,它等待一下,看看弹出是否在它杀死之前被处理掉了。这为我带来了许多挫败感。我还有一个版本可以匹配从文件中读取的标题或正文中的某些关键字 - 这样我就可以避免杀死需要留下的内容。

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;   AutoIt Version:     3.1.0                                               ;
;   Author:             Dave McNulla                                        ;
;   Script Function:    Close unwanted popups during test automation.       ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
Opt("WinTextMatchMode", 1)  ;0=best, 1=quick
Opt("WinTitleMatchMode", 2)     ;1=start, 2=subStr, 3=exact, 4=advanced
Opt("TrayIconHide", 0) ;0=show, 1=hide
Opt("TrayMenuMode", 0) ;0=default
TraySetIcon("Shell32.dll", 98)

dim $SleepTime = 2000
dim $Max = 100

$Message = "{ENTER}"
$ButtonClick = "[CLASS:Button; TEXT:OK]"
$Title = "[CLASS:#32770;TITLE:Internet Explorer]"

While 1
    If WinExists($Title) Then
        WinActivate($Title)
        Sleep($SleepTime)
        ControlClick($Title, "", $ButtonClick)
    EndIf
    Sleep($SleepTime)
    If $Max < 1 Then Exit(1)
WEnd