您可以使用 Touchaction 类点击 editText 字段中的 Cross 选项。
尝试使用下面的代码
// Identify the x and y co-ordinate for EditText field
Point elementLoc = driver.findElement(By.xpath("xpath of edittext field")).getLocation();
int eleX = elementLoc.getX();
int eleY = elementLoc.getY();
// Identify the width and height of the editText field
Dimension elementDimen = driver.findElement(By.xpath("xpath of edittext field")).getSize();
int eleH = elementDimen.getHeight();
int eleW = elementDimen.getWidth();
// Determine the x and y co-ordinates of cross option
int touchX = (int)(eleX + eleW * 0.75D); // 75% from the x co-ordinate of editText field ( x axis position for cross option)
int touchY = (int)(eleY + eleH * 0.5D); // 50 % from the y co-ordinate of editText field (y axis position for cross option)
// Tap on the cross option
TouchAction<?> action = new TouchAction(driver);
action.tap(PointOption.point(touchX, touchY)).release().perform();
在找到交叉选项的确切位置之前,请尝试使用 touchX 和 touchY 变量的偏移值。