Error getting on Appium, Cannot set the element to 'value'. Did you interact with the correct element?

I am doing automation of the app using appium. I am able to lunch the app but I go for login, it can read the XPath for login. But appium is unable to enter the mobile number. For mobile device, I am using the emulator.

This is my code:

driver.findElement(By.xpath(props.getProperty("mobile"))).sendKeys("123456");

This is my Xpath:

mobile=//android.widget.EditText[@text='Mobile']

Error facing:

Encountered internal error running command: io.appium.uiautomator2.common.exceptions.InvalidElementStateException: Cannot set the element to ‘value’. Did you interact with the correct element?

it might be the field has some special input validators, which prevent sendKeys method to work properly on it. Try to send the text via actions or via mobile: type (the latter is only available since v. 1.17 or in appium@beta and supports input of Unicode characters)

@mykola-mokhnach Thanks. But will explain to me how should I send the key-value via mobile. bcoz when I run the code “Unicode IME” gets enable and “Gboard” gets disable automatically. This is the reason I am unable to enter send key value in the path.

@Swapna_Das

Add the below two capabilities to your code to enable the keyboard.

capabilities.setCapability(“unicodeKeyboard”, false);
capabilities.setCapability(“resetKeyboard”, false);

Send keys using action class as follows:

driver.findElement(By.xpath(props.getProperty(“mobile”))).click();
Actions action = new Actions(driver);
action.sendKeys(“Mobile”).perform();

6 Likes

you know what. Especially to Say thanks to you only i registered my account in site. i am testing android in appium. trying send keys to textbox since three days. but failed. i did browse almost all sites like stackoverflow. nothing seems to work your suggestion works for me. really very very Thanks boss.

You are just awesome…:clap::clap::clap:

Thanks @pothurajtharun, the solution worked perfectly for me. I was aware of Actions Class but was not sure whether it would work for native codes or not. Luckily it worked, Thanks man!