Espresso : How to click on an item at position 2 in AdapterView - android

I am new to Espresso and Mobile Testing, and I am facing a challenge. I have to search for a contact in App and click on contact displayed at second position.
I checked many posts which were similar but however none of those worked for my example.
Code to Search : onView(withId(R.id.textSearch)).perform(typeText("pa"));
Code to Select : onView(withText("Parth Vyas")).perform(click());
But here if I want to select any element which is displayed at position 2, how can I do that?

If you know the position after search, then you can try something like:
onData(anything()).inAdapterView(YOUR_ADAPTER_VIEW_MATCHER).atPosition(2).perform(click());

Related

Firebase Search event Term not showing in analytics

I report a Search event and add the search query to the bundle.
In Firebase, only the event is shown. I can see the stat on the search event log, but I can't see the value of the Term that were searched. From what I understand, the Term param is supported by Firebase.
Here is my code:
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.SEARCH_TERM, query);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SEARCH, bundle);
What should I do to get the search term to appear in `Firebase?
You can use custom definitions to solve this problem.
Here's how
Go to firebase console
Then select the custom definition from the left panel
click on "create custom dimension" at the top right
Then enter the details as shown in this photo
After entering detail give it some time and then make a search event from your app.
now go to the events tab -> select search event -> and you will see your search term with the count in a separate card.
More info about the custom dimensions
From what I can understand from your code in the question, the code does not have any errors.
If you are implementing firebase analytics for the first time, it will take 24 hours for the events to appear in the dashboard.
After first event reported, next events takes around 3-4 hours to update in google dashboard.
Hope this info helps :)

Android/Firebase Trying to show nested objects retrieved from Firebase in adapter

I'm trying to show a list of songs on a recyclerview in android, nothing too fancy. something like this:
Song1
in Album a
-Song2
in Album a
-Song3
in Album b
So far so good; also, my firebase db looks something like this (in my app, a song cannot be on two albums, so bear with me)
songs:
-idSong1:
description:"Song1"
album: idAlbumA
-idSong2:
description:"Song2"
album: idAlbumA
-idSong3:
description:"Song3"
album: idAlbumB
albums:
-idAlbumA:
description:"Album a"
-idAlbumB:
description:"Album b"
Okay, enter Android adapters. I set a firebase valueListener to songs, retrieve all of them and pass them on to the adapter. The problem is, I still don't have the description of their albums.
Let me clarify, I do have the id's of the albums, but I'm forced to set a value listener of every item to find out the album description. I'm not familiar with firebase but it doesn't take much to know that that can't be right. I would be setting and removing listener a lot when the user scrolls through the song list.
There is a high chance I might be approaching this whole thing the wrong way. So any kind of advice is welcome.
Lastly, I want to congratulate the guys at firebase for such an amazing product!
Well, it turns out what I was trying to do was to simply do a JOIN between two nodes. and here's how it's done: https://www.firebase.com/blog/2013-10-01-queries-part-one.html

Calabash android, as clicking a ListView?

I've been looking for the answer on the Internet, but could not find it. help me please.
How to make pressing the list item in Calabash-Android?
Try this out
Add a definition to ruby step file.
Then /^I scroll to cell with "([^\"]*)" label and touch it$/ do |name|
element="TextView text:'#{name}'"
if !element_exists(element)
wait_poll(:until_exists => "TextView text:'#{name}'", :timeout => WAIT_TIMEOUT) do
performAction('scroll_down')
end
if element_exists(element)
touch(element)
sleep(STEP_PAUSE)
else
screenshot_and_raise "could not find the cell"
end
else
touch(element)
sleep(STEP_PAUSE)
end
end
and call it from feature file Then I scroll to cell with "cellMainLabel" label and touch it
The answer above looks a bit more fool proof than mine but I have been using the following quite happily:
spinner selection
Then (/^I select spinner by id "(.*?)"$/) do |spinnerid|
touch("spinner id:'#{spinnerid}'")
end
select an item in the damn spinner
Then (/^I touch "(.*?)"$/) do |text|
touch("TextView text:'#{text}'")
end
it's two steps, first part will select the spinner via its id and then the second part selects the item in the spinner via the text you quoted.

Android application structure issue

I'm working on application and I need some suggestions which is the best way to code it for Android. Basically it's something like event guide for a few cities. Imagine this :
I have an activity with 7 different buttons (7 different cities) and clicking on one of these buttons I'm opening a new activity where I have all months (January-December) as buttons again. If there is some event in February for example in the chosen city the button will be active and I will go to another activity where I have a list with the events. So my idea is to do it in this way :
Create one Activity with all Cities
Create one Calendar activity with all months.
When user select for example Paris, I'll send an extra via intent with an ID of the chosen city :
intent.putExtra("chosenCity", 2); //something like this
In the Calendar activity I will make active/inactive months buttons depending on that extra sent from Cities activity.
And when user chose a month I will send that chosenCity extra again to the ListViewEvents activity and populate the list view from Database (for example) depending on that extra.
So my question is : is it a good way to build an application like that? Or if it's not, which is the best way to achieve this?
Thanks in advance!
Sounds like you already know pretty much what you need to do. The only thing left is to implement it. The only thing I'll add is that your should probably store all your database and use a CursorAdapter to display them in the ListView. You can store all the events in the database and just create your select statement in such a way that it only selects the events you want to display at any given time. When using this CursorAdapter, I highly recommend you use the CursorLoader.

logical problem in an android app

hi i would like to know solution for such a problem..... i have an xml file containing users data of around 1000 users listed out in alphabetical order. The xml file use to be as follow
<usersdata>
<user>
<id>1</id>
<firstname>A</firstname>
<middlename>AA</middlename>
......
......
</user>
<user>
<id>2</id>
<firstname>B</firstname>
<middlename>BB</middlename>
......
......
</user>
........
........
</usersdata>
Now from the above xml file i am parsing all the tags and storing them in an array list for each tag. I am listing out the Firstname in a listview, by array list of first name. When the any of the list is clicked, it opens up a new activity where the all other details of the selected name is been shown.
For example if third name in the list is clicked, by using its position(example 3), in the next activity i am listing out the third values stored in all the array lists i am using. This is what currently i am doing.
Now the problem is i have a edit box above the list view, named as a search box. If the letter S is typed in it, then all the names starting with S gets listed first. Opening the next activity by clicking the list now gets some wrong data, how to avoid this.
Please give me a suggestion....
For example if the first name C is clicked, it will be listed at position 3
There is a quick and dirty hack: you can store user id in the invisible field, retrieve it on click and use it as an argument for the second activity. I'm afraid I can't come up with better suggestions without seeing the code.
i tried out by setting some flag and by using an example code in developers site. And i am able to list out the data's but this idea does not full fill my apps requirement in the next activity. So i removed the search part in my app.
Sorry for posting such a question here......

Categories

Resources