sendKey not working for android.view.View class

My appium version is 1.4.16.1.

There is an object on the screen (a passcode field) where I want to pass some text into it.
Below are the details of it:
index 1
text
resource-id FLD_PASSCODE_item
class android.view.View
package glb.farms.mobile
content-desc Passcode

I am using the following code:
driver_and.findElement(By.xpath("//android.view.View[@resource-id=‘FLD_PASSCODE_item’]")).sendKeys(“1234”);

I am observing that the sendKeys feature is not working. Can anybody help here please.

I am also attaching the screenshot of the image taken from the UIAutomator tool.

try driver.tap() before using send keys

WebElement element = driver.findElement(By.xpath(" "));
driver.tap(element);
element.sendKeys(“some-text”);

@amitjaincoer191, i think this element is inside web view. so It will not work if remoteDebug option is not enable with UIAutomator. If that is the case then i think switch to selendroid mode is better option.

@Priyank_Shah
Yes u r right my mistake, in UI Hierarchy I missed to see this class “android.webkit.WebView”

We have different way to handle webView elements. Elements under this class “android.webkit.WebView” are inside webview.

Helper Link : http://toolsqa.com/mobile-automation/appium/how-to-inspect-and-automate-webview-in-hybrid-app/

@amitjaincoer191 and @Priyank_Shah : Just one clarification i would like to make and that is ,the class here were are talking about is of the type andriod.view.View.

But it is under parent “android.webkit.WebView” see this class u can see if u see above …

To clarify, these elements are rendered as web browser and not as android native elements inside app so to handle these elements we have different way …

The app should be rebuild with webview debugger enabled
You need to setContext of app to webview
You need to inspect these elements in chrome browser instead of appium inspector / uiautomator viewer

Is there any documentation where I can go through for the same plz

official documentation
https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/hybrid.md

or
I explained it here
http://toolsqa.com/mobile-automation/appium/how-to-inspect-and-automate-webview-in-hybrid-app/

1 Like

I will share with you another image from the same app, where even if it is in Webcontext mode, but still I can be able to use the sendkeys features. Can you explain me plz why the same is happening then please.

@amitjaincoer191 Thanks very much! I think this is very helpful for what I’m going to meet with.

Hi @sayom88;

were you able to find a solution for this ? I’m facing the same issue
Thanks in advance

try using set_text("[email protected]") or uninstall current selenium install selenium==3.3.1

You can watch this : https://www.youtube.com/playlist?list=PLXbcghgSZDroz9nez1IrbL2hnMVJ0ba1W