3

I am working on a testing environment that consists of the following technologies: Jenkins, Genymotion and calabash-android. Using ionic, I have a built a simple todo app - in fact it's the one found as part of this guide (http://ionicframework.com/docs/guide/installation.html). I have then written a simple feature for calabash_android, and accompanying steps, to test this app.

Feature file:

Feature: Todo's & Projects
      Scenario: I can create a new todo under a project
        Given I wait for 5 seconds
        When I press button with id "new__task"
        Then I see field with id "#input__text"
        Then I enter text "This is a test" into input with id "#input__text"
        When I press button with id2 "create__task"
        Then I see id "task__1"
        Then I take a screenshot

      Scenario: I can create a new project
        Given I wait for 5 seconds
        When I swipe left
        Then I see button with id "#new__project"

Steps:

require 'calabash-android/calabash_steps'
When(/^I press button with id "(.*?)"$/) do |buttonid|
       query("CordovaWebView css:'#new__task'")
       touch("CordovaWebView css:'#new__task'")
end
Then(/^I see field with id "(.*?)"$/) do |fieldid|
    query("CordovaWebView css:'#input__text'")
end
Then(/^I enter text "(.*?)" into input with id "(.*?)"$/) do |text, fieldid|
    query("CordovaWebView css:'#input__text'")
    enter_text("CordovaWebView css:'#input__text'", "This is a test")
end
When(/^I press button with id2 "(.*?)"$/) do |buttonid|
    query("CordovaWebView css:'#create__task'")
    touch("CordovaWebView css:'#create__task'")
end
Then(/^I see id "(.*?)"$/) do |fieldid|
    query("CordovaWebView css:'#task__1'")
end
Then(/^I see button with id "(.*?)"$/) do |buttonid|
       query("CordovaWebView css:'#new__project'")
       touch("CordovaWebView css:'#new__project'")
end

When I run this, it succeeds. All the steps pass, both scenarios pass, everything's great.

If I then add crosswalk using "ionic browser add crosswalk", i run into some issues.

These steps I've written stop working, because "CordovaWebView" no longer exists. I expect this, since crosswalk embeds everything in it's own view.

The problem is that I can't query that view. When I launch the new crosswalk'd app with calabash-android console, I can "query("")" - This shows about 9 different views, the one of interest being "XWalkCordovaView". However if I then substitute "CordovaWebView" in my steps with "XWalkCordovaView" - The steps still fail. Indeed, querying XWalkCordovaView like so: "query("XWalkCordovaView css:''") gives me nothing, whereas if I do that in the noncrosswalk app, with CordovaWebView, i get all the css elements on the page (as expected).

I can't really /not/ test the app. But I need crosswalk for the optimisations and ability to test on x86 architecture.

So...how do I successfully query and manipulate elements within the CrosswalkCordova view? Am I looking in the right place? No one seems to know, I've googled many times and the top result is always a github user asking if crosswalk is supported "natively" (which it's not).

Any help would be appreciated.

2 Answers2

0

I am not familiar with the Cordova stack, but I was talking to one of my colleagues @ Xamarin who is in charge of Calabash Android.

Here is an excerpt from a relevant GitHub issue. Crosswalk support #507

Examining the widget gave the following results:

irb(main):006:0> query "org.apache.cordova.CordovaWebView", :getClass
[
    [0] "org.apache.cordova.CordovaWebView"
]
irb(main):007:0> query "org.apache.cordova.CordovaWebView", :getClass, :getSuperclass
[
    [0] "org.xwalk.core.XWalkView"
]
irb(main):008:0> query "org.apache.cordova.CordovaWebView", :getClass, :getSuperclass, :getSuperclass
[
    [0] "android.widget.FrameLayout"
]

We can see that the widget does not inherit form android.webkit.WebView, and it is therefore not recognised as a valid WebView. We do not plan to work around this for now, pull requests are always welcome.

jmoody
  • 2,480
  • 1
  • 16
  • 22
  • Unfortunately I've come across that specific issue many times in my searches. I've done some experimenting with that query (i.e finding out the superclass of the XWalkCordovaView) and it does appear that this is still the problem. Do you think there's any way of working around this? I've worked out an alternate workflow that means I only add crosswalk /after/ testing, but obviously a solution would be preferred. – Apple_Master Jan 28 '15 at 16:35
0

Calabash-Android 0.5.6 (released today) introduces crosswalk support. Your queries should be valid when you update Calabash-Android.

Tobias
  • 678
  • 4
  • 9