Re: Android testing embedded web views

400 views
Skip to first unread message

Yahor Paulavets

unread,
Jan 9, 2013, 3:39:37 AM1/9/13
to androidtestautomation, robotium-...@googlegroups.com, teste...@gmail.com, rena...@gmail.com
Hello,

1) Did you try Selenium WebDriver for Android?

2) Do you have mechanism to execute javascript?

You can't execute nothing, until (source: http://developer.android.com/reference/android/webkit/WebView.html):

A WebView has several customization points where you can add your own behavior. These are:

  • Creating and setting a WebChromeClient subclass. This class is called when something that might impact a browser UI happens, for instance, progress updates and JavaScript alerts are sent here (see Debugging Tasks).
  • Creating and setting a WebViewClient subclass. It will be called when things happen that impact the rendering of the content, eg, errors or form submissions. You can also intercept URL loading here (viashouldOverrideUrlLoading()).
  • Modifying the WebSettings, such as enabling JavaScript with setJavaScriptEnabled().
  • Injecting Java objects into the WebView using the addJavascriptInterface(Object, String) method. This method allows you to inject Java objects into a page's JavaScript context, so that they can be accessed by JavaScript in the page.
Best regards,
Yahor

On Mon, Dec 31, 2012 at 5:36 PM, androidtestautomation <androidtes...@gmail.com> wrote:
Hi,

I am using robotium 3.6 for to automate android web views.

and I am trying to write a test case as per below:

public void test01() {
Activity activity = getActivity(); 
WebView web;
ArrayList<View> views = solo.getCurrentViews();
for(View view : views) {
if(view instanceof WebView) {
web = (WebView) view;
break;
}

// Here i need to execute JavaScript commands on my WebView from Robotium test.
}
}

Can any body help me to verify web elements ?


Regards,
Reddy

Reply all
Reply to author
Forward
0 new messages