Unable to query elements in webview in my android app - android

I am using Calabash to automate my app. So in my app when i tap on pay now it opens a payment page in web view where i need to enter the card details etc. But when i am trying to query the element in this page view i am not getting any elements listed. It only shows one web view but elements inside is not listed. please suggest me what i need to do to get all the elements inside web view.
I have tried all the commands provided by calabash for querying in web view in app but all are returning zero results.

I was able to solve this problem using following:
Step 1:
query for classes '*' which will return all the classes
Step 2: Check which web view is being used in your screen. for me it was advanced web view. query for your web view using query("AdvancedWebView css:'*’")
Step 3: It will show you all the elements in your screen. Now you can query for each element.
Example: query("AdvancedWebView xpath:'//SPAN’")

Related

webview- window.getselection() value is coming null

I am working on an android application,which has a WebView. in this web view when i select the html text and perform any action the window.getSelection() is coming null.
One javascript method window.getSelection() doesn't return the selected text from WebView every time. Many developers raised issues to Google for this but no solutions. https://issuetracker.google.com/issues/36925404
I tried all possible option to get the selection object like
window.getSelection(); window.doument.getSelection(); document.getSelection(); EReader.Selection.Range.getCurrentRange();
Do you have any suggestions?

Android application xpath with content desc - handle the line break

Objective: To click on Access for all guest users.
I am unable to find this element.
uiautomatorviewer shows the following screenshot.
Content description is following copy/pasted
"Access for all guest users
Provider not listed? Stay tuned, we will be adding more TV providers shortly."
Notice: the line break after user. I believe this is why my xpath is not working.
My xpath is:
"//android.view.View[#content-desc ='Access for all guest usersProvider not listed? Stay tuned, we will be adding more TV providers shortly.']"
I cannot use index instead of content-desc because of the object in layers above have the same class and index.
Using tap to a specific might solve the problem but is not a good solution.
any ideas on how to handle that linebreak.
If you notice the XML hierarchy, you will notice that your element is inside a WebView (3rd node from top). So its not getting identified. You have to first switch to WebView and then use your code.
The way you mentioned the xpath should work, once you switch to WebView.

Best way to display first doc in a view using the UnpBootFormViewer

I am trying to display the first document in a view using the "UnpBootFormViewer".
What I have currently done is include the "UnpBootFlatView" control that references a view which contains only one (1) document (app settings in this instance). I have it in a "" with the style set to "display: none;".
This works great on a computer using a standard browser, but when the same app is opened on a mobile device (Nexus 5) it does nto work.
Is there a better/easier way to do what I'm trying?
I assume you use native document data source. To initialize it with first document from some view you must provide UNID of that document. Example:
var v:View = database.getView("view name");
var vec:ViewEntryCollection = v.getAllEntries();
var ve:ViewEntry = vec.getFirstEntry();
var unid = ve.getUniversalID();
return unid;
I recommend to use your preferred error catching technique (try/catch, OpenLog...)
Why so complicated - ViewEntryCollection and ViewNavigator collections keep documents sorted as in view. Common beginner's mistake is to use view.getFirstDocument() - this document is the first from internal list of documents so it need not to be the first document shown in the view.
I think what you are trying to do is possible and I think it's demostrated in this page from the sample app provided by Teamstudio
My Activities Page
This uses the UnpBootFlatView to look up the activities based you your username. It then uses the UnpBootFormViewer to display the first document in the view.
The XPage to reference is MyActivities
The documentations also points out that from release 1.3 of the XControls 'openfirstdocument' is defaulted to 'yes'. If you have this set to anything else the first document in the view will not load.
Flat View Documentation
If that's all fine on the standard browser as you suggest and it just doesn't work on the Android device, then I'd suggest contacting Teamstudio Support.
Tim C. ;o)
[Disclosure] Tim Clark works for Teamstudio

Match a View in WebView from Espresso in Android

I want to match the user name text field inside a WebView which loads the Salesforce login page (but can also be applied to any other page with text fields).
I have tried with:
onView(withHint("User Name")).perform(typeText("test#sf.com"));
But that doesn't work. Any better idea?
This can be accomplished using Espresso Web 2.2 API
onWebView().withElement(findElement(Locator.ID,"username")).perform(webKeys("test#sf.com"));
Please use Locator.Xpath if you don't know ID.
To find xpath first you need to check the html code based on which you can write xpath.
To get html source code you can use chrome inspector.
connect the device to the PC and then open chrome inspector.You can right click on the html code and click on copy xpath to get the xpath.
You can fill form just run js code in WebView.
For example:
webView.loadUrl("
javascript:document.getElementById('username-field').value = 'test#sf.com’;
");

How do I do a lazy load of images in ListView from PHP server to Android

I am new to android & exploring it.I need to load image of User dynamically in my list shown below
list of Users!
I use one static image to show as user image from my resource folder. this list is dynamic & get change as my location get change but only when i refresh it.
AddObjectToList(jFan_Data.getString("uniqid").toString(),R.drawable.ic_add, jFan_Data.getString("name"), jFan_Data.getString("distance"));
on click of the list item need to display the complete profile of user. i succeed to show complete profile on click i need to show image of user here as well
user_profile!
How i get the data from php(Please gone through) -> android List View having jsonObject
now how i get images of users from my php server... would greatly appreciate any sample code,scripts, and pointers to where I could find more information to better understand the inner working. Also, pretty much interested to know how i use other framework or is there are better frameworks to do what I want to, I am happy to learn about that!!!

Categories

Resources