question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android Mobile] Unable to find elements in android.webkit.WebView component

See original GitHub issue

The problem

I am running testings on a React Native application. Inside that app I have a WebView component, I am trying find a certain element inside this WebView but with no success. The Appium API I tried using are:

  • find_element_by_xpath
  • find_element_by_id
  • find_elements_by_class_name
  • find_element_by_accessibility_id

The elements inspector does showing me correctly the element: Screen Shot 2020-06-30 at 8 32 40

The element view in the app found in the following image, at the bottom: Screen Shot 2020-06-30 at 8 43 53

Environment

  • Appium version (or git revision) that exhibits the issue: 1.16.0 and 1.17.1
  • Last Appium version that did not exhibit the issue (if applicable):None
  • Desktop OS/version used to run Appium:CLI
  • Node.js version (unless using Appium.app|exe):12.16.0
  • Npm or Yarn package manager:npm
  • Mobile platform/version under test: Android
  • Real device or emulator/simulator:Emulator
  • Appium CLI or Appium.app|exe:CLI

Details

If necessary, describe the problem you have been experiencing in more detail.

Link to Appium logs

https://assets-production.applicaster.com/qa/zapp_qa/manual/boaz/html_appium.log

Code To Reproduce Issue [ Good To Have ]

Please remember that with sample code it’s easier to reproduce the bug and it’s much faster to fix it.

Please git clone https://github.com/appium/appium and from the sample-code directory, use one of your favourite languages and sample apps to reproduce the issue.

In case a similar scenario is missing in sample-code, please submit a PR with one of the sample apps provided.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
KazuCocoacommented, Jul 1, 2020

I don’t think Appium can do much take care of them for now, unfortunately, since the root depends on how Android framework handles WebView components. So, potentially your workaround could be the only current solution until Google modifies the logic. (Or React Native side??)

https://github.com/appium/appium-uiautomator2-server/blob/c0d2d45740a2f9d05cf0e6c3b7b1a19e2f85d1b1/app/src/main/java/io/appium/uiautomator2/handler/FindElement.java#L88-L112

https://github.com/appium/appium-uiautomator2-server/blob/c0d2d45740a2f9d05cf0e6c3b7b1a19e2f85d1b1/app/src/main/java/io/appium/uiautomator2/model/internal/CustomUiDevice.java#L52

import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.UiSelector;

Potentially, espresso driver handles them better than uiautomator.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to inspect element from android application's webview
Navigate to a portion of your app where a web view is active. Retrieve the currently available contexts. This returns a list of...
Read more >
Android webview contains empty html source, can't ... - GitHub
Typically elements under(child elements) android.webkit.WebView will be considered as WEBVIEW, here you are referring android.webkit.WebView in ...
Read more >
Android.WebKit.WebView is not finding element (button)
Hi I'm using Appium Studio to run a sequence of tests on my own mobile app. But on my app there is a...
Read more >
How to Identify WebView Elements in Android Hybrid App?
We can't identify WebView elements by using UIAutomatorViewer insdie Android Sdk. Appium Inspector is unable to capture the device screen in latest Appium.exe...
Read more >
WebView - Android Developers
android :paddingEnd, Sets the padding, in pixels, of the end edge; see ... a WebView is created or any other methods in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found