[arquillian-issues] [JBoss JIRA] (ARQGRA-385) Unable to use Guards with AndroidDriver (again)
Lukáš Fryč (JIRA)
jira-events at lists.jboss.org
Mon Sep 30 10:03:02 EDT 2013
[ https://issues.jboss.org/browse/ARQGRA-385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12808257#comment-12808257 ]
Lukáš Fryč commented on ARQGRA-385:
-----------------------------------
I think the cause is:
{code}
LOGCAT: I/AndroidWebDriver( 756): Executing: [execute script: /* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc. and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */window.Graphene = window.Graphene || {};window.Graphene.Page = window.Graphene.Page || {};window.Graphene.Page.RequestGuard = (function() { var requestType = "HTTP"; var requestState = "DONE"; var filters = []; function replaceTimeout(xhr) { xhr.originalTimeout = window.setTimeout; window.setTimeout = function(originalCallback, timeout) { if (timeout > window.Graphene.Page.RequestGuard.maximumCallbackTimeout) { xhr.originalTimeout.apply(window, arguments); } else { xhr.callbackCount += 1; var callbackArguments = []; for (var i = 0; i < arguments.length; i++) { if (i >= 2) { callbackArguments.push(arguments[i]); } } xhr.originalTimeout.call(window, function() { try { replaceTimeout(xhr); if (typeof(originalCallback) == 'string') { window.eval(originalCallback); } else { originalCallback(callbackArguments); } } finally { revertTimeout(xhr); xhr.callbackCount -= 1; xhr.tryFinish(); } }, timeout); } } } function revertTimeout(xhr) { window.setTimeout = xhr.originalTimeout; xhr.originalTimeout = null; } function enhanceXhrObject(xhr) { xhr.guarded = true; xhr.callbackCount = 0; xhr.changeState = function(type, state) { if (this.guarded) { requestType = type; requestState = state; } }; xhr.tryFinish = function() { if (this.callbackCount === 0) { this.changeState("XHR", "DONE"); } }; xhr.proceedWithCallbacks = function(context, args) { if (this.guarded) { replaceTimeout(this); try { context.proceed(args); } finally { revertTimeout(this); } } else { context.proceed(args); } }; xhr.isGuarded = function() { for (var i = 0; i < filters.length; i++) { var filter = filters[i]; try { if (!eval(filter)) { return false; } } catch (e) { console.log('failed to filter XHR request "' + filter + '": ' + e.message); } } return true; }; } return { maximumCallbackTimeout : 50, getRequestType : function() { return requestType; }, getRequestState : function() { return requestState; }, clearRequestDone : function() {
LOGCAT: W/AndroidWebDriver( 756): Exception thrown
LOGCAT: W/AndroidWebDriver( 756): org.openqa.selenium.WebDriverException: Error: {"message":"Unexpected token return"}
LOGCAT: W/AndroidWebDriver( 756): Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
LOGCAT: W/AndroidWebDriver( 756): System info: os.name: 'Linux', os.arch: 'armv7l', os.version: '2.6.29-gc497e41', java.version: '0'
LOGCAT: W/AndroidWebDriver( 756): Driver info: driver.version: EventFiringWebDriver
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.android.library.AndroidWebDriver.throwIfError(AndroidWebDriver.java:1024)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.android.library.AndroidWebDriver.executeRawScript(AndroidWebDriver.java:895)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.android.library.AndroidWebDriver.injectJavascript(AndroidWebDriver.java:930)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.android.library.AndroidWebDriver.executeScript(AndroidWebDriver.java:786)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.android.AndroidApkDriver.executeScript(AndroidApkDriver.java:106)
LOGCAT: W/AndroidWebDriver( 756): at java.lang.reflect.Method.invokeNative(Native Method)
LOGCAT: W/AndroidWebDriver( 756): at java.lang.reflect.Method.invoke(Method.java:511)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
LOGCAT: W/AndroidWebDriver( 756): at $Proxy1.executeScript(Native Method)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.support.events.EventFiringWebDriver.executeScript(EventFiringWebDriver.java:209)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteScript.java:55)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteScript.java:1)
LOGCAT: W/AndroidWebDriver( 756): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
LOGCAT: W/AndroidWebDriver( 756): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
LOGCAT: W/AndroidWebDriver( 756): at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
LOGCAT: W/AndroidWebDriver( 756): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
LOGCAT: W/AndroidWebDriver( 756): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
LOGCAT: W/AndroidWebDriver( 756): at java.lang.Thread.run(Thread.java:856)
LOGCAT: W/AndroidWebDriver( 756): Exception: Error: {"message":"Unexpected token return"}
{code}
What is the last Graphene version which worked for you?
The problem had to be introduced in one of those commits (history of RequestGuard.js <= Alpha5):
https://github.com/arquillian/arquillian-graphene/commits/2.0.0.Alpha5/graphene-webdriver/graphene-webdriver-impl/src/main/javascript/Graphene.Page.RequestGuard.js
> Unable to use Guards with AndroidDriver (again)
> -----------------------------------------------
>
> Key: ARQGRA-385
> URL: https://issues.jboss.org/browse/ARQGRA-385
> Project: Arquillian Graphene
> Issue Type: Bug
> Components: core
> Affects Versions: 2.0.0.CR1
> Environment: Selenium APK 2.32.
> Reporter: Karel Piwko
> Priority: Critical
> Fix For: 2.0.0.Final
>
>
> It is not possible to use Guards on Android driver, it fails with following error:
> {code}
> java.lang.IllegalStateException: Can't invoke the javacript org.jboss.arquillian.graphene.guard.RequestGuardImpl#clearRequestDone()
> at org.openqa.selenium.android.library.AndroidWebDriver.throwIfError(AndroidWebDriver.java:1024)
> at org.openqa.selenium.android.library.AndroidWebDriver.executeRawScript(AndroidWebDriver.java:895)
> at org.openqa.selenium.android.library.AndroidWebDriver.injectJavascript(AndroidWebDriver.java:930)
> at org.openqa.selenium.android.library.AndroidWebDriver.executeScript(AndroidWebDriver.java:786)
> at org.openqa.selenium.android.AndroidApkDriver.executeScript(AndroidApkDriver.java:106)
> at java.lang.reflect.Method.invokeNative(Native Method)
> at java.lang.reflect.Method.invoke(Method.java:511)
> at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
> at $Proxy1.executeScript(Native Method)
> at org.openqa.selenium.support.events.EventFiringWebDriver.executeScript(EventFiringWebDriver.java:209)
> at org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteScript.java:55)
> at org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteScript.java:1)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
> at java.util.concurrent.FutureTask.run(FutureTask.java:137)
> at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
> at java.lang.Thread.run(Thread.java:856)
> {code}
> I've tested both *guardAjax(...)* and *guardNoRequest(...)* guards.
> Together with ARQGRA-384, this significantly reduces usability of Graphene when combined with AndroidDriver.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the arquillian-issues
mailing list