Do hybrid apps work at all yet with Appium?

1,052 views
Skip to first unread message

daen

unread,
Sep 12, 2013, 4:25:26 AM9/12/13
to appium-...@googlegroups.com
Hello,

I'm not able to get Appium interact with hybrid apps, like explained in the documentation here.

I can't even get a list of the window handles, it just returns

FAILED: test
org.openqa.selenium.WebDriverException: Not yet implemented.

Am I missing something? I'm using an Android Phonegap App and following the procedure from the doc. I even found an example for Phonegap in the appium github repo, I guess this should work then?

If it helps, here my testclass:

public class TestClassPairingWizardAppium {

WebDriver driver;
@BeforeMethod
public void setup() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
capabilities.setCapability(CapabilityType.VERSION, "4.2.2");
capabilities.setCapability(CapabilityType.PLATFORM, "Windows");
capabilities.setCapability("app-package", "com.example.testapp");
capabilities.setCapability("app-activity", "TestActivity"); 
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@Test
public void test() {
System.out.println("Printing available Window Handles:\n");
for (String handle : driver.getWindowHandles()) {
System.out.println("Handle: " + handle);
}
}
@AfterClass
public void teardown() {
// close the app
driver.quit();
}

}

Please help me.

Jonathan Lipps

unread,
Sep 12, 2013, 5:27:48 AM9/12/13
to Daniel Hess, appium-...@googlegroups.com
What is appium log?

On Sep 12, 2013, at 11:26 AM, Daniel Hess <dal4...@googlemail.com> wrote:

Hi,

thanks a lot for your answer. But as soon as I use 
capabilities.setCapability("device", "selendroid");
, I get the following error:

org.openqa.selenium.remote.SessionNotFoundException: A session is either terminated or not started (Original error: java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.cordova.hellocordova.selendroid/io.selendroid.ServerInstrumentation} from pid=25959, uid=25959 not allowed because package io.cordova.hellocordova.selendroid does not have a signature matching the target io.cordova.hellocordova

You got a hint for me?


2013/9/12 Jonathan Lipps <jli...@gmail.com>
You need to use Selendroid for webview automation. These desired caps should work:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device", "selendroid");
capabilities.setCapability("app-package", "com.example.testapp");
capabilities.setCapability("app-activity", "TestActivity"); 
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

Then follow the instructions to switch to webview etc


--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.



daen

unread,
Sep 12, 2013, 6:22:29 AM9/12/13
to appium-...@googlegroups.com
it looks like somehow selendroid signs the apk with a different key?

 
C:\Users\da.hess\AppData\Roaming\npm\node_modules\appium>node server.js --app-pk
g "io.cordova.hellocordova" --app-activity "HelloCordova" --app "C:\xampp\htdocs
\phonegap\SimpleTest\platforms\android\bin\SimpleTest.apk"
info: Welcome to Appium v0.9.0 (REV 1ed240811d9a586fb1913d400585a7e29dbe96b0)
info: Appium REST http interface listener started on 0.0.0.0:4723
   info  - socket.io started
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"app-package":"io.c
ordova.hellocordova","device":"selendroid","app-activity":"HelloCordova"}}
info: Using local app from command line: C:\xampp\htdocs\phonegap\SimpleTest\pla
tforms\android\bin\SimpleTest.apk
info: Creating new appium session af4518d7-8110-4ea7-9ed1-894cb3c3e2d6
info: Starting selendroid server
info: Checking whether selendroid is built yet
info: Selendroid server exists!
info: Starting selendroid
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
info: [ADB] Using adb from C:\adt-x86_64\sdk\platform-tools\adb.exe
info: Trying to find a connected android device
info: [ADB] Getting connected devices...
info: [ADB] 1 device(s) connected
info: [ADB] Setting device id to 5851d8ba
info: Found device, no need to retry
info: [ADB] Waiting for device 5851d8ba to be ready and to respond to shell comm
ands (timeout = 5)
info: Starting logcat capture
info: Checking whether we need to run fast reset
debug: APK doesn't exist. C:\Windows\Temp\io.cordova.hellocordova.clean.apk
debug: Checking app cert for C:\xampp\htdocs\phonegap\SimpleTest\platforms\andro
id\bin\SimpleTest.apk: java -jar "C:\Users\da.hess\AppData\Roaming\npm\node_modu
les\appium\app\android\verify.jar" "C:\xampp\htdocs\phonegap\SimpleTest\platform
s\android\bin\SimpleTest.apk"
debug: App already signed.
debug: App signed? true C:\xampp\htdocs\phonegap\SimpleTest\platforms\android\bi
n\SimpleTest.apk
info: Building fast reset
info: Checking whether aapt is present
info: [ADB] Using aapt from C:\adt-x86_64\sdk\build-tools\android-4.3\aapt.exe
info: Compiling manifest C:\Windows\Temp\AndroidManifest.xml
debug: "C:\adt-x86_64\sdk\build-tools\android-4.3\aapt.exe" package -M "C:\Windo
ws\Temp\AndroidManifest.xml" --rename-manifest-package "io.cordova.hellocordova.
clean" --rename-instrumentation-target-package "io.cordova.hellocordova" -I "C:\
adt-x86_64\sdk\platforms\android-18\android.jar" -F "C:\Windows\Temp\AndroidMani
fest.xml.apk" -f
debug: Compiled manifest
info: Inserting manifest, src: C:\Users\da.hess\AppData\Roaming\npm\node_modules
\appium\app\android\Clean.apk, dst: C:\Windows\Temp\io.cordova.hellocordova.clea
n.apk
debug: Extracting manifest
info: Unzipping C:\Windows\Temp\AndroidManifest.xml.apk
info: Testing zip archive: C:\Windows\Temp\AndroidManifest.xml.apk
info: Zip archive tested clean
info: Unzip successful
debug: Writing tmp apk. C:\Users\da.hess\AppData\Roaming\npm\node_modules\appium
\app\android\Clean.apk to C:\Windows\Temp\io.cordova.hellocordova.clean.apk
debug: Testing new tmp apk.
info: Testing zip archive: C:\Windows\Temp\io.cordova.hellocordova.clean.apk
info: Zip archive tested clean
debug: Moving manifest with: "C:\JDK64\bin\java.exe" -jar "C:\Users\da.hess\AppD
ata\Roaming\npm\node_modules\appium\app\android\move_manifest.jar" "C:\Windows\T
emp\io.cordova.hellocordova.clean.apk" "C:\Windows\Temp\AndroidManifest.xml"
debug: Inserted manifest.
debug: Skip app sign. Sign clean apk.
debug: Resigning apks with: java -jar "C:\Users\da.hess\AppData\Roaming\npm\node
_modules\appium\app\android\sign.jar" "C:\Windows\Temp\io.cordova.hellocordova.c
lean.apk" --override
info: Rebuilt selendroid apk exists, doing nothing
info: Rebuilt selendroid server already exists, no need to rebuild it with a new
 manifest
info: Checking signed status of C:\Windows\Temp\selendroid.io.cordova.hellocordo
va.apk
debug: Checking app cert for C:\Windows\Temp\selendroid.io.cordova.hellocordova.
apk: java -jar "C:\Users\da.hess\AppData\Roaming\npm\node_modules\appium\app\and
roid\verify.jar" "C:\Windows\Temp\selendroid.io.cordova.hellocordova.apk"
info: Checking signed status of C:\xampp\htdocs\phonegap\SimpleTest\platforms\an
droid\bin\SimpleTest.apk
debug: Checking app cert for C:\xampp\htdocs\phonegap\SimpleTest\platforms\andro
id\bin\SimpleTest.apk: java -jar "C:\Users\da.hess\AppData\Roaming\npm\node_modu
les\appium\app\android\verify.jar" "C:\xampp\htdocs\phonegap\SimpleTest\platform
s\android\bin\SimpleTest.apk"
debug: App already signed.
debug: App already signed.
debug: Getting install/clean status for io.cordova.hellocordova.selendroid
info: Rebuilt selendroid is already installed
info: Determining app install/clean status
debug: Getting install/clean status for io.cordova.hellocordova
info: [ADB] Installing clean apk
info: Installing C:\Windows\Temp\io.cordova.hellocordova.clean.apk
debug:  pkg: /data/local/tmp/io.cordova.hellocordova.clean.apk

Success


debug: Running fast reset clean: "C:\adt-x86_64\sdk\platform-tools\adb.exe" -s 5
851d8ba shell am instrument io.cordova.hellocordova.clean/clean.apk.Clean
info: [ADB] Forwarding system:8080 to device:8080
info: [ADB] Attempting to unlock screen
info: Starting instrumentation process for selendroid with cmd: "C:\adt-x86_64\s
dk\platform-tools\adb.exe" -s 5851d8ba shell am instrument -e main_activity 'io.
cordova.hellocordovaHelloCordova' io.cordova.hellocordova.selendroid/io.selendro
id.ServerInstrumentation
error: java.lang.SecurityException: Permission Denial: starting instrumentation
ComponentInfo{io.cordova.hellocordova.selendroid/io.selendroid.ServerInstrumenta
tion} from pid=27885, uid=27885 not allowed because package io.cordova.hellocord
ova.selendroid does not have a signature matching the target io.cordova.hellocor
dova

        at android.os.Parcel.readException(Parcel.java:1425)

        at android.os.Parcel.readException(Parcel.java:1379)

        at android.app.ActivityManagerProxy.startInstrumentation(ActivityManager
Native.java:3148)

        at com.android.commands.am.Am.runInstrument(Am.java:675)

        at com.android.commands.am.Am.run(Am.java:119)

        at com.android.commands.am.Am.main(Am.java:82)

        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)

        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243)

        at dalvik.system.NativeStart.main(Native Method)


info: Overriding session id with ,,,,,,,,,,,,,,,,,,
error: Failed to start an Appium session, err was: Error: java.lang.SecurityExce
ption: Permission Denial: starting instrumentation ComponentInfo{io.cordova.hell
ocordova.selendroid/io.selendroid.ServerInstrumentation} from pid=27885, uid=278
85 not allowed because package io.cordova.hellocordova.selendroid does not have
a signature matching the target io.cordova.hellocordova

info: Responding to client with error: {"status":6,"value":{"message":"A session
 is either terminated or not started (Original error: java.lang.SecurityExceptio
n: Permission Denial: starting instrumentation ComponentInfo{io.cordova.hellocor
dova.selendroid/io.selendroid.ServerInstrumentation} from pid=27885, uid=27885 n
ot allowed because package io.cordova.hellocordova.selendroid does not have a si
gnature matching the target io.cordova.hellocordova\r\r)","origValue":"java.lang
.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io
.cordova.hellocordova.selendroid/io.selendroid.ServerInstrumentation} from pid=2
7885, uid=27885 not allowed because package io.cordova.hellocordova.selendroid d
oes not have a signature matching the target io.cordova.hellocordova\r\r"},"sess
ionId":null}
POST /wd/hub/session 500 7206ms - 801
info: Clearing out appium devices

Jonathan Lipps

unread,
Sep 12, 2013, 6:55:07 AM9/12/13
to daen, appium-...@googlegroups.com
Yes, that does look to be the problem. Bootstrap, can you see anything in the logs that looks off?

Maybe try deleting everything from the device to make sure there's no conflicts

adb uninstall io.cordova.hellocordova
adb uninstall io.cordova.hellocordova.clean
adb uninstall io.cordova.hellocordova.selendroid

daen

unread,
Sep 12, 2013, 7:12:54 AM9/12/13
to appium-...@googlegroups.com, daen
I think I got nearer to the solution... There seems to be some problem with signing. Now I exported my apk unter Eclipse->File->Export->Export Android Application with my debug keystore and now it seems to work!

Now I'll try to access my elements of the WebView


C:\Users\da.hess\AppData\Roaming\npm\node_modules\appium>node server.js --app-pk
g "io.cordova.hellocordova" --app-activity "HelloCordova" --app "C:\Users\da.hes
s\Desktop\SimpleTest.apk"
info: Welcome to Appium v0.9.0 (REV 1ed240811d9a586fb1913d400585a7e29dbe96b0)
info: Appium REST http interface listener started on 0.0.0.0:4723
   info  - socket.io started
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"app-package":"io.c
ordova.hellocordova","device":"selendroid","app-activity":"HelloCordova"}}
info: Using local app from command line: C:\Users\da.hess\Desktop\SimpleTest.apk

info: Creating new appium session 5e426c81-9248-43b4-a710-056a1366f1f7
info: Starting selendroid server
info: Checking whether selendroid is built yet
info: Selendroid server exists!
info: Starting selendroid
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
info: [ADB] Using adb from C:\adt-x86_64\sdk\platform-tools\adb.exe
info: Trying to find a connected android device
info: [ADB] Getting connected devices...
info: [ADB] 1 device(s) connected
info: [ADB] Setting device id to 5851d8ba
info: Found device, no need to retry
info: [ADB] Waiting for device 5851d8ba to be ready and to respond to shell comm
ands (timeout = 5)
info: Starting logcat capture
info: Checking whether we need to run fast reset
debug: Checking app cert for C:\Windows\Temp\io.cordova.hellocordova.clean.apk:
java -jar "C:\Users\da.hess\AppData\Roaming\npm\node_modules\appium\app\android\
verify.jar" "C:\Windows\Temp\io.cordova.hellocordova.clean.apk"
debug: App already signed.
debug: Checking app cert for C:\Users\da.hess\Desktop\SimpleTest.apk: java -jar
"C:\Users\da.hess\AppData\Roaming\npm\node_modules\appium\app\android\verify.jar
" "C:\Users\da.hess\Desktop\SimpleTest.apk"
debug: App already signed.
debug: App signed? true C:\Users\da.hess\Desktop\SimpleTest.apk
info: Rebuilt selendroid apk exists, doing nothing
info: Rebuilt selendroid server already exists, no need to rebuild it with a new
 manifest
info: Checking signed status of C:\Windows\Temp\selendroid.io.cordova.hellocordo
va.apk
debug: Checking app cert for C:\Windows\Temp\selendroid.io.cordova.hellocordova.
apk: java -jar "C:\Users\da.hess\AppData\Roaming\npm\node_modules\appium\app\and
roid\verify.jar" "C:\Windows\Temp\selendroid.io.cordova.hellocordova.apk"
info: Checking signed status of C:\Users\da.hess\Desktop\SimpleTest.apk
debug: Checking app cert for C:\Users\da.hess\Desktop\SimpleTest.apk: java -jar
"C:\Users\da.hess\AppData\Roaming\npm\node_modules\appium\app\android\verify.jar
" "C:\Users\da.hess\Desktop\SimpleTest.apk"
debug: App already signed.
debug: App already signed.
debug: Getting install/clean status for io.cordova.hellocordova.selendroid
info: Rebuilt selendroid is not installed, installing it
info: Installing C:\Windows\Temp\selendroid.io.cordova.hellocordova.apk
debug:  pkg: /data/local/tmp/selendroid.io.cordova.hellocordova.apk

Success


info: Determining app install/clean status
debug: Getting install/clean status for io.cordova.hellocordova
info: [ADB] Installing app apk
info: Installing C:\Users\da.hess\Desktop\SimpleTest.apk
debug:  pkg: /data/local/tmp/SimpleTest.apk

Success


info: [ADB] Forwarding system:8080 to device:8080
info: [ADB] Attempting to unlock screen
info: Starting instrumentation process for selendroid with cmd: "C:\adt-x86_64\s
dk\platform-tools\adb.exe" -s 5851d8ba shell am instrument -e main_activity 'io.
cordova.hellocordovaHelloCordova' io.cordova.hellocordova.selendroid/io.selendro
id.ServerInstrumentation
info: Selendroid server is launching
info: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status
","method":"GET"}
info: Selendroid server is alive!
info: Creating Selendroid session
info: Making http request with opts: {"url":"http://localhost:8080/wd/hub/sessio
n","method":"POST","json":{"desiredCapabilities":{"app-package":"io.cordova.hell
ocordova","device":"selendroid","app-activity":"HelloCordova"}}}
info: Successfully started selendroid session
info: Waiting for app's activity to become focused
info: Getting focused package and activity
info: Getting focused package and activity
info: Getting focused package and activity
error: App never showed up as active. appActivity: com.android.launcher2.Launche
r != HelloCordova
info: Selendroid hasn't started app yet, let's do it manually with adb.startApp
info: Starting app
info: [ADB] Starting app
"C:\adt-x86_64\sdk\platform-tools\adb.exe" -s 5851d8ba shell am start -n io.cord
ova.hellocordova/HelloCordova
info: We tried to start an activity that doesn't exist, retrying with . prepende
d to activity
info: Starting app
info: [ADB] Starting app
"C:\adt-x86_64\sdk\platform-tools\adb.exe" -s 5851d8ba shell am start -n io.cord
ova.hellocordova/.HelloCordova
info: Waiting for app's activity to become focused
info: Getting focused package and activity
info: Overriding session id with 3a86b526-6f09-46b7-abd2-28bb16b7886e
info: Appium session started with sessionId 3a86b526-6f09-46b7-abd2-28bb16b7886e

POST /wd/hub/session 303 21803ms - 9
debug: Appium request initiated at /wd/hub/session/3a86b526-6f09-46b7-abd2-28bb1
6b7886e
debug: Proxying command to localhost:8080
info: Making http request with opts: {"url":"http://localhost:8080/wd/hub/sessio
n/3a86b526-6f09-46b7-abd2-28bb16b7886e","method":"GET"}
debug: Proxied response received with status 200: "{\"value\":{\"platform\":\"an
droid\",\"acceptSslCerts\":true,\"javascriptEnabled\":true,\"handlesAlerts\":fal
se,\"browserName\":\"selendroid\",\"rotatable\":false,\"takesScreenshot\":true,\
"version\":\"0.5.0\"},\"status\":0,\"sessionId\":\"3a86b526-6f09-46b7-abd2-28bb1
6b7886e\"}"
GET /wd/hub/session/3a86b526-6f09-46b7-abd2-28bb16b7886e 200 26ms - 249
debug: Appium request initiated at /wd/hub/session/3a86b526-6f09-46b7-abd2-28bb1
6b7886e/window
debug: Request received with params: {"name":"WEBVIEW"}
debug: Proxying command to localhost:8080
info: Making http request with opts: {"url":"http://localhost:8080/wd/hub/sessio
n/3a86b526-6f09-46b7-abd2-28bb16b7886e/window","method":"POST","json":{"name":"W
EBVIEW"}}
debug: Proxied response received with status 200: {"value":"","status":0,"sessio
nId":"3a86b526-6f09-46b7-abd2-28bb16b7886e"}
POST /wd/hub/session/3a86b526-6f09-46b7-abd2-28bb16b7886e/window 200 123ms - 87
debug: Appium request initiated at /wd/hub/session/3a86b526-6f09-46b7-abd2-28bb1
6b7886e
info: Shutting down appium session...
info: Stopping selendroid server
info: Making http request with opts: {"url":"http://localhost:8080/wd/hub/sessio
n/3a86b526-6f09-46b7-abd2-28bb16b7886e","method":"DELETE"}
info: Killing app
info: Clearing out appium devices
info: Responding to client with success: {"status":0,"value":null,"sessionId":"3
a86b526-6f09-46b7-abd2-28bb16b7886e"}
DELETE /wd/hub/session/3a86b526-6f09-46b7-abd2-28bb16b7886e 200 782ms - 89

daen

unread,
Sep 12, 2013, 9:19:29 AM9/12/13
to appium-...@googlegroups.com, daen
I was wrong, the problem was not about signing. Executing the steps you described solved it. Thanks so far!



Am Donnerstag, 12. September 2013 12:55:07 UTC+2 schrieb Jonathan Lipps:

bootstrap online

unread,
Sep 12, 2013, 9:36:41 AM9/12/13
to daen, appium-...@googlegroups.com
I'm glad you got it working. The best way to fix Android signing
issues is to uninstall the apks and have Appium install them. Appium
will override the signatures as needed.

Teemu Kanstrén

unread,
Sep 12, 2013, 4:43:47 PM9/12/13
to appium-...@googlegroups.com
Hi,

 I am also trying to test a hybrid app and have some similar problems. Is my understanding from this thread correct that I would need to specify "selendroid" as device type and not "Android"? If I do, the "full reset" feature of Appium does not seem to be invoked as it is when using "Android" as the type. I need to be able to reset the app between tests. 

 The API for finding items seems to function differently between the tools. And I am sure there are other issues hiding, so I would rather stay with one tool (Appium in this case). Is there any way to interact with a webview direct from Appium?  Or can I switch between the two somehow on the fly?

Thanks,
Teemu

Jonathan Lipps

unread,
Sep 12, 2013, 8:21:58 PM9/12/13
to Teemu Kanstrén, appium-...@googlegroups.com
Hi Teemu,

Appium and Selendroid are in the process of reconciling APIs. Until then, you'll have to familiarize yourself with both as necessary.

Jonathan

daen

unread,
Sep 13, 2013, 4:27:57 AM9/13/13
to appium-...@googlegroups.com, Teemu Kanstrén
For the timeline, is this a matter of days, weeks, or months? :)

Jonathan Lipps

unread,
Sep 13, 2013, 4:45:59 AM9/13/13
to daen, appium-...@googlegroups.com, Teemu Kanstrén
Months. Or between weeks and months :-)
Reply all
Reply to author
Forward
0 new messages