How to enter value in an element if “auto-move-next” has been set for the elements in appium script?

up vote
0
down vote
favorite
I have an android application to automate where user has to configure PIN after logging into the application. PIN page has only four blank boxes where when user enters 1st PIN, cursor automatically moves to second box. It keeps moving till 4th box automatically once user has entered value in previous box and after all 4 values are set, Set PIN buttons get enabled.

While I am trying to enter values into these boxes via Selenium script, the cursor keeps moving back and forth entering values in random boxes, but it never enter values in all the boxes and execution ends.

I have tried following ways:

  1. wait.until(ExpectedConditions.elementToBeClickable(elem1).click();

elem1.senKeys(“1”);
//Moves to random boxes

  1. JavascriptExecutor myExecutor = ((JavascriptExecutor) driver); myExecutor.executeScript(“document.getElementsByName(‘pin1’).value=‘1’”);

//org.openqa.selenium.WebDriverException: Not yet implemented.

  1. if(“pin1”.equals(elem1.getAttribute(“name”)))

{

elem1.sendKeys(“1”);
}

else

{

new Actions(driver).moveToElement(elem1).perform().sendKeys(“1”);
}

//org.openqa.selenium.WebDriverException: Not yet implemented.

  1. UiSelector uiSelector = new UiSelector(); uiObject1 = new UiObject(uiSelector.description(“pin1”)); uiObject1.setText(“1”);

//RuntimeException:Stub

  1. driver.switchTo().defaultContent(); elem.sendKeys(“1”);

//Nothing happens

  1. By meX1 = By.name(“pin1”);

MobileElement me1 = (MobileElement) driver.findElement(meX1);

TouchAction touchAction1 = new TouchAction((MobileDriver) driver);

touchAction1.longPress(me1, 1000).release();

(PerformsTouchActions) driver).performTouchAction(touchAction1);

((AndroidDriver)driver).getKeyboard().pressKey("");
me1.sendKeys(“1”);

//Moves to random boxes

The issue is script and the code both are trying to move to boxes, probably which is creating confusion.

Hey Shalini,
Were you able to find solution to this problem? I am also facing the exact same issue while simulating PIN elements