Selenium & Firefox: How can i turn off “Unresponsive script” warnings?

后端 未结 7 1177
慢半拍i
慢半拍i 2021-02-05 17:42

I\'m using Selenium Client 2.4.0 on Mac 10.6.6 with Firefox 5. Using the WebBackedSeleniumDriver, I\'m running a \"selenium.getEval\" command that causes a Firefox warning,

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 18:01

    Although this thread is quite old, the problem still exists with current selenium and firefox builds. I've got these really annoying messages quite a long time now, without a good fix. Asking the devolopers / mailing list / google usually results in the following answer:

    The javascript used in your application is too fat or buggy, improving your scripts will help.

    As this is no option in a larger company, when you depend on a framework you have no access to, i decided to search for the root cause for myself.

    The core of the problem is the fact, that selenium overrides profile settings if you specify the -timeout nnnn parameter. So creating a custom firefox profile template and setting the dom.max_script_run_time and dom.max_chrome_script_run_time will not work here.

    As soon as you specify the -timeout parameter, these two settings are overriden with the value you provide to the parameter. After hours of debugging and testing i noticed some facts:

    • If you don't specify -timeout, firefox runs for exact 30 minutes, without one script timeout. After that, firefox gets killed by selenium with a SeleniumCommandTimedOutException
    • As soon as you specify -timeout (no matter which value), the script timeout appears after several seconds or minutes. These messages are independent to the timeout-value.
    • The -browserTimeout parameter isn't usefull as i haven't found where this parameter is used in the source.

    As we have some testsuites that run longer than 30 minutes we have 2 options to fix this behaviour:

    • Rewriting our testsuites and splitting them to run within the 30 minutes window
    • Patching selenium to run longer than 30 minutes

    Do not use the -timeout parameter.

    So choose for yourself which option is better. I created a small and simple patch for the HTMLLauncher.java to allow 90 minutes instead of the default 30.

    diff --git a/java/server/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java b/java/server/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java
    index c2296a5..310b39f 100644
    --- a/java/server/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java
    +++ b/java/server/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java
    @@ -146,6 +146,16 @@
         launcher.launchHTMLSuite(suiteURL, browserURL);
    
         sleepTight(timeoutInMs);
    +    // SFR, Patch 2013-10-17: To get rid of the damn SeleniumCommandTimedOutException
    +    // we allow the Suite to run 3 times as long as per default (30 min -> 90 min).
    +    if(results == null) {
    +      log.warning("SFR, Patch 2013-10-17");
    +      sleepTight(timeoutInMs);
    +    }
    +    if(results == null) {
    +      log.warning("SFR, Patch 2013-10-17");
    +      sleepTight(timeoutInMs);
    +    }
    
         launcher.close();
    

    I'll upload a pre-compiled jar with the above patch if necessary.

提交回复
热议问题