3

I am unable to locate Recycler view using Appium

Screenshot

When I try to locate the RecyclerView, the Appium server just halts. In this image (ListView) I want to check the checkbox which is highlighted in the image.

The approach I am using is findingElementbyid("Recyclerview") get its index and click on checkbox.

Can you please guide the right approach?

Shri
  • 31
  • 3

1 Answers1

0

You need not find the recyclerView. You can do the following

@AndroidFindBy(xpath = "//android.widget.Button[@text='Primary Account']") private List primaryAccounts;

or

@AndroidFindBy(id= "com.ezepay:id/bMakePrimary") private List primaryAccounts;

Then, in order to click on a particular button, you can do the following click(primaryAccounts.get(index));

Shrirang
  • 198
  • 1
  • 10
  • Thanks. Could you please elaborate on private List and primaryAccounts? – Shri Jan 18 '19 at 13:45
  • Your intention to click on the Primary Account checkbox. So, `@AndroidFindBy(xpath = "//android.widget.Button[@text='Primary Account']") private List primaryAccount`; will return list of Primary Account checkbox available on the recyclerview. Once you have the list, you can click on any particular checkbox using it's index – Shrirang Jan 18 '19 at 16:57
  • Thanks. Where do I need to use this? I get the error @AndroidFindBy is disallowed for this location. How to perform click action as well? I am sorry, I am very new to this and I am stuck at listView for finding elements – Shri Jan 18 '19 at 18:04
  • **Here is my code** I am unable to post my entire snippet as there is a character limit from StackOverflow @Test(priority = 5) public void testSelectingPrimaryAccount() throws InterruptedException { @AndroidFindBy(xpath = "//android.widget.Button[@text='Primary Account']") private List primaryAccount; I am placing the above code after the execution of the login, adding a bank account and the screen which you can see above. Thank you – Shri Jan 19 '19 at 05:51
  • You need to declare the `@AndroidFindBy(xpath = "//android.widget.Button[@text='Primary Account']")` `private List primaryAccounts`; outside the test method. – Shrirang Jan 19 '19 at 08:05
  • If I declare outside the test Method How can I perform the action in the flow? Here, how do I say Appium to click on that checkbox which I want to click? Can you please explain? – Shri Jan 19 '19 at 08:06
  • Can you try the below – Shrirang Jan 21 '19 at 03:07
  • 1
    `List primaryAccount = appiumDriver.findElements(By.id("com.ezepay:id/bMakePrimary"))' In order to click on a particular element `primaryAccount.get(index).click();` Hope this helps – Shrirang Jan 21 '19 at 03:16
  • Thanks @Shrirang. Unfortunately, it is not working, I tried in all possible ways. I am unable to locate the locator. I used the tap gesture, it is working fine for now. But, it is a bad approach. Unsure, how to do this. Need to see, if anyone else faced this issue – Shri Jan 23 '19 at 06:38