Reputation: 193
I am using Appium via Robot Framework. I am able to use click element and perform actions. But when it comes to selecting a value from drop down, there is no inbuilt command from appium.
My example: I am trying on redbus mobile app. I have a calendar, where I need to select some date say 21.
I am able to find the resource id of the element 21, but it is same for all the numbers in the calender.
Here 'resource id' is same but 'text' is changing according to numbers. My 'resource id' is in.redbus.android:id/gridCellin.redbus.android:id/gridCell
.
click element of that resource id is not clicking 21 because resource id is same for all numbers.
Please help me. I got stuck here.
Upvotes: 3
Views: 2854
Reputation: 193
At last I found the solution for my problem.
I am using robot framework. So, I used xpath=//*[@text=21]
Using xpath works fine almost every time, except if there is any special character in any of the nodes.
I am trying to get solution for that special character case as well. I will post once I find the answer.
Upvotes: 3
Reputation: 101
You can reference an element in many ways, including classname, id, and text. Have you tried finding the element you need by text? If that doesn't work then you could use class name and instance, although that is not as accurate.
ID: find_element_by_id(your_date_id)
Class: find_element_by_class_name(your_class_name,instance_number)
Text: find_element_by_name(21)
If you haven't used UIAutomatorViewer then I recommend using it to find the different identifiers you can use for your element.
Upvotes: 0