0

でJSコードを実行しようとすると、以下の例外が発生しfirefox 17.0ます。 v2.32changelog は、それがサポートしていると述べています10esr, 17esr, 19, 20。また、最新の webdriver バージョンが2.35、使用しているいくつかのテストのロケーターの問題によるものであることも認識していv2.32ます。これは完全に機能しますchrome v29

それを修正する方法について何か考えはありますか?前もって感謝します

コードは次のとおりです。

public void commonWaitForAjax() throws Exception {
        for (int i=1; i<100; i++) {
      //    String status = selenium.getEval("$.active");   // fails here (legacy selenium method)
            String jsCode = "$.active";
            JavascriptExecutor js = (JavascriptExecutor) driver;
            printComment("executing: "+ jsCode);
            String status = (String) js.executeScript(jsCode); // fails here too (webdriver method)
            printComment("status: " + status);
            if( Integer.valueOf(status) == 0) {
                printComment("Ajax complete!!!");
                break;
            } else {
                printComment("Waiting for Ajax to complete...");
                Thread.sleep(1000);
            }
        }
    }

これはコンソールに記録されます:

Sep 09, 2013 1:32:32 PM org.openqa.selenium.internal.seleniumemulation.WaitForPageToLoad handleSeleneseCommand
WARNING: Cannot determine whether page supports ready state. Abandoning wait.

例外

testMetersOverview(marklogic.test.MetersOverview)
com.thoughtworks.selenium.SeleniumException: waiting for evaluate.js load failed
Command duration or timeout: 10.26 seconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_25'
Session ID: 5399e6a6-8134-4c08-b6d2-13716b8b96e2
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=23.0.1}]
    at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:44)
    at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:40)
    at org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:140)
    at org.openqa.selenium.WebDriverCommandProcessor.getString(WebDriverCommandProcessor.java:111)
    at com.thoughtworks.selenium.DefaultSelenium.getEval(DefaultSelenium.java:479)
    at marklogic2.Common.commonWaitForAjax(Common.java:1172)
    at marklogic.test.MetersOverview.testMetersOverview(MetersOverview.java:111)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
    at org.junit.runner.JUnitCore.runMain(JUnitCore.java:96)
    at org.junit.runner.JUnitCore.runMainAndExit(JUnitCore.java:47)
    at org.junit.runner.JUnitCore.main(JUnitCore.java:40)
Caused by: org.openqa.selenium.WebDriverException: waiting for evaluate.js load failed
Command duration or timeout: 10.26 seconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_25'
Session ID: 5399e6a6-8134-4c08-b6d2-13716b8b96e2
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=23.0.1}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:463)
    at org.openqa.selenium.internal.seleniumemulation.GetEval.handleSeleneseCommand(GetEval.java:39)
    at org.openqa.selenium.internal.seleniumemulation.GetEval.handleSeleneseCommand(GetEval.java:1)
    at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:35)
    ... 39 more
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: waiting for evaluate.js load failed
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_25'
Driver info: driver.version: unknown
    at <anonymous class>.r(file:///C:/Users/sreddy/AppData/Local/Temp/anonymous7980890323570416361webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js:8321)
    at <anonymous class>.fxdriver.Timer.prototype.runWhenTrue/g(file:///C:/Users/sreddy/AppData/Local/Temp/anonymous7980890323570416361webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js:392)
    at <anonymous class>.fxdriver.Timer.prototype.setTimeout/<.notify(file:///C:/Users/sreddy/AppData/Local/Temp/anonymous7980890323570416361webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js:386)

FAILURES!!!
Tests run: 1,  Failures: 1
4

1 に答える 1

0

次のように、実行中の JS スクリプトで return を実行する必要があります。

String status = (String) js.executeScript("return STARTED");
于 2013-09-19T06:38:02.240 に答える