We’re trying to automate one of our Test cases on iOS (iPad) with appium-java client 8.
The test step is like below:
- Fetch element from TextField
- Click on that textField
- Clear the existing value and enter the new value
Test Result:
- We’re able to fetch the value from the TextField
- Click action is successful but the actual interaction is not working. Due to which the sendkeys also not working
Note: The above scenario was working fine with approach 1 with TestProject. Now we’ve migrated the framework to appium. After that only it’s failing few scenarios
Please review the attached DOM Appium Inspector- Actual Element
Tried Approaches 1. Approach 1
{
element.getAttribute("value");
element.click();
element.sendkeys("newvalue");
}
-> Test Result:
- We’re able to fetch the value from the TextField
- Click action is successful but the actual interaction is not working. Due to which the sendkeys also not working
2. Actions Class
{
Actions action = new Actions(appiumDriver);
WebElement element = appiumDriver.findElement(byLocator);
element.getAttribute("value");
action.moveToElement(element).click().perform();
action.moveToElement(element).sendKeys(Keys.chord(Keys.CONTROL, "a")).perform();
element.clear();
element.sendKeys(""+text);
appiumDriver.hideKeyboard();
}
Test Result:
- We’re able to fetch the value from the TextField
- Click action is successful but the actual interaction is not working. Due to which the sendkeys also not working
3. With W3C action
{
PointerInput FINGER = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence tap = new Sequence(FINGER, 1)
.addAction(FINGER.createPointerMove(Duration.ofMillis(0),PointerInput.Origin.viewport(), (element.getRect().x + (element.getSize().width/2)), element.getRect().y))
.addAction(FINGER.createPointerDown(0))
.addAction(new Pause(FINGER, Duration.ofMillis(200)))
.addAction(FINGER.createPointerUp(0));
appiumDriver.perform(Arrays.asList(tap));
}
Test Result:
- We’re able to fetch the value from the TextField
- Click action is working fine. However it’s clicking on different location. Same thing happening when we try to find element in appium inspector. The locator is correct but still the coordinates are different one.