we are very proud to introduce you new way of testing WebView in your applications. Especially to record and playback tests for html-based application embedded in WebView (for instance by using PhoneGap framework).
We extended our recorder-extensions library using by playback tests and we implemented recognition of actions on HTML elements inside WebView in the newest version of Testdroid Recorder.
Recording from WebView
Now we are recording following commands on HTML elements in WebView:
- clickOnHtmlElement(String tag, String id, String name, String class, int index)
- enterTextIntoHtmlElement(String tag, String id, String name, String class, String text, int index)
- waitForHtmlElement(String tag, String id, String name, String class, int index, int time)
In addition you can easily add following asserts using append command during recording:
- elementExistsOnHtmlPage(String tag, String id, String name, String class, int index)
- isTextPresentOnHtmlPage(String text)
We also provide one additional auxiliary method to get whole html from WebView:
As you can see in commands above, we are recognizing HTML elements on five parameters. Tag is obligatory, rest are optional. Tag, id, name, class are HTML attributes, index is our parameter. There can be few elements with the same attributes, so we are indexing them.
Possibilities and limitations
We are able to record and playback actions on WebView, if you fulfill a few limitations.
- Firstly your WebView has to have WebViewClient set for WebView.
Recording actions from WebView requires to load the script inside the page. This may take some time, so please be patient, if the actions are not recorded. Same playing tests need to load scripts and create an appropriate interface between the WebView and Eclipse. Therefore, playing tests may take a little longer than they were recorded.
We have prepared simple demo usage of Testdroid Recorder to record actions from WebView. Enjoy: