Skip to content
krukow edited this page Dec 20, 2012 · 10 revisions

Calabash Android supports querying and acting on webview content.

To look into a webview you simply use the query function and syntax. The syntax for webviews is a bit irregular (and we will clean this up at some point), but there is quite good support.

Here are some examples:

  1. Query for an element with id, class or tagname

    query("webView css:#header") query("webView css:.js-current-repository") query("webView css:a")

The string after css: can be any css selector.

  1. Get all the HTML associated with the webview:

    query("webView css:*")

Note query will only return DOM nodes that are visible on the screeen! (They should be visible and their center should be within the webview viewport).

Touching

As usual, anything you can query, you can touch (but the element must be visible to be found).

query("webView css:a").first
touch("webView css:'a'")

Entering text

You can use the set_text function to set the text using JavaScript (your query must be a textfield or textarea).

set_text "webView css:input.login", "ruk"
Clone this wiki locally