Support Center

Recorder and WebView handling

Last Updated: Aug 06, 2013 11:36AM CEST

Overview

Since version 2.4, TestDroid Recorder does not record simple clicks as x,y positions in the WebView but it is able to look inside the html code of the WebView, analyse the code, and record actions based on html elements. It's a very important feature as more and more applications are implemented using partly HTML as well as many applications use WebView to implement for example the login view.

Recorded and manual commands

We are recording the following commands from WebView:
  • clickOnHtmlElement(tag, id, name, class, index, custom_attributes...)
  • enterTextIntoHtmlElement(tag, id, name, class, text, index, custom_attributes...)
  • waitForHtmlElement(tag, id, name, class, index, time, custom_attributes...)
  • htmlGoBack
  • htmlGoForward
  • htmlZoomIn
  • htmlZoomOut
Additionally you can easily add following asserts using append command during recording:
  • elementExistsOnHtmlPage(tag, id, name, class, index, custom_attributes...)
  • isTextPresentOnHtmlPage(text)
Index parameter is offset of elements found by previous parameters (to be sure we always get only one element). Custom_attributes is a list of any additional attributes beyond tag, id, name and class you want to use to restrict recognition of html elements. You can specify this list in preference page: in eclipse Window->Preferences->Tesdroid->WebView.

We also provide a few auxiliary method:
  • getHtmlCode - to get whole html code from WebView - needed to manuall use it inside result code
  • injectJavaScriptCode(code) - to inject dynamically own JS script code into WebView
  • injectJavaScriptFile(file) - the same like above but this method get code from given file - remember that root directory for this file is asset folder in your test.
You can use all above methods manually in your java code using our free public library "ExtSolo" -
http://docs.testdroid.com/_pages/extsolo.html.

Playback WebView tests

If you want to use this feature, there are couple of points you should be aware of:
  • If you record your test on device with Android 4.1 you need to have a WebViewClient connected to your WebView.
  • If you implement your own WebView class and override loadUrl method or implement your own WebViewClient and override shouldOverrideUrlLoading you need to be carefull to not break URLs with prefix 'javascript:' because of the possibility of loading JS into WebView is required to perform recording in your application.
Below we share a short video from first tests of recording from WebView:
https://docs.google.com/open?id=0B6Q9me_GpvI1c0c3cWdYVXl0V1k

Contact Us

support@bitbar.com
http://assets2.desk.com/
false
bitbar
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete