简体   繁体   中英

How do i assert text in the android webview

I have an application to test which has many webviews . i want to assert some strings in the webviews .i use robotium for testing and as robotium as of now doesn't support webviews i am in a fix .please help me in this .

If you have webview instance, you can use method loadUrl and inject some js. To comunicate java and js inside webview you will need javascript interface, which you can add with method addJavascriptInterface.

You can always use ExtSolo provided by Testdroid, which has this functionality (isTextPresentOnHtmlPage or elementExistsOnHtmlPage): http://docs.testdroid.com/_pages/extsolo.html

It doesn't look like you can get the contents of a WebView from the WebView itself for security reasons. Here are some questions on SO that reference this issue:

You could use one of these methods to get the HTML for comparison.

Also, I haven't used this myself yet, but Android FEST looks very cool and can make some assertions about WebViews, though I can't tell if you can look at the contents of the WebView with it.

You can! You can use Bitbar extension for Solo. Here it is available and downloadable: http://docs.testdroid.com/_pages/extsolo.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM