Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android get text from browser

I want to get text from browser by using uiautomator

How can I do it?

I've parsed structure of chrome and there is only android.View.view
I've tried to use getText() function, but it's not helped.
Any help appreciated.

Maybe somebody know how can I do it by calling some chrome instance... or with any other method.

Any solution, with info, how to save android browser page as html/text will be enough, or how to select whole page. (except touching/long pressing text).

like image 226
Laser Avatar asked Aug 02 '13 12:08

Laser


2 Answers

UiDevice.getLastTraversedText() is the only way I know to get highlighted text in webview. I am also looking for a better way to test webview on Android.

like image 171
Xiaocong Avatar answered Oct 15 '22 16:10

Xiaocong


Weirdly, UiDevice.getLastTraversedText() has never worked for me. Since Android 4.4 though, the elements are exposed as the android.view.View with its text or function as content descriptors. Does not work all the time, but it is a large improvement.

like image 40
Micha Avatar answered Oct 15 '22 15:10

Micha