This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
7 / 7
Mar 2018

There are no elements in the current page, I see the only className but remaining sections also having the same className, I have tried it so many ways but still getting null pointer exception

  1. Taken from Parent node but this case also not working.
  2. Used findElements:

List elements = driver.findElements(By.className(“android.widget.RelativeLayout”));
element.get(0).click();

  1. driver.findElementByXPath("//android.widget.TextView[@index=‘0’]).click();

Thanks

  • created

    Mar '18
  • last reply

    Mar '18
  • 6

    replies

  • 503

    views

  • 3

    users

  • 2

    likes

  • 2

    links

All elements are visible in your screen. Even the texts (Y C., PREMIUM, Irvine, CA) are visible.

You want to tap on first element of the list? Look for the parent element of the results list and then look for the class names below that parent element, for instance.

Hi Telmo_Cardoso,

Yes, there are visible texts but not every time, it will change randomly (Eg: take facebook news feed )

Yes I have tried it to take parent element and the child element to click, still getting null pointer exception.

See Parent list className is diff when compared to the child (See the first screenshot) element className

so unable to click first member

To tap on first element:

driver.findElement(By.id(“com.care.android.careview.debug:id/recyclerview”)).findElements(By.className(“android.widget.RelativeLayout”)).get(0).click();

Off course this shouldn’t be so directly. You should use waits and verification if elements is retrieving any element before getting the first index to avoid NullPointer, etc.

@Telmo_Cardoso this will only work for first element. With second one will not cause there are many RelativeLayouts inside each other.

@kumar.abdasu best solution ask DEV to add resource-ID to RelativeLayouts on first screenshot. It is 1 line of code.

yes @Aleksei I’m giving the solution he wanted :smiley:

Using xpath he can get the direct childs with that class only:

"//" + CLASSNAME_ANDROID_RECYCLER_VIEW + "/" + CLASSNAME_ANDROID_RELATIVELAYOUT