can';找不到android AutoCompleteTextView元素

can';找不到android AutoCompleteTextView元素,android,mobile,automated-tests,appium,uiautomatorviewer,Android,Mobile,Automated Tests,Appium,Uiautomatorviewer,我无法访问标记的X元素 已经和开发人员谈过了,他们说不可能在其上放置id或可访问性标记,他们说是这种元素类型 我会通过x和y位置来做,但是如果我使用硬编码的数字,它会在不同分辨率的设备上中断 如何更有效地定位此元素 我使用appium进行测试自动化,但这对于任何测试自动化框架来说都是一个问题 图像中使用的工具是uiautomatorviewer 您应该尝试使用元素的类。 driver.findElement(By.className(“android.widget.EditText”) 如果出现

我无法访问标记的X元素

已经和开发人员谈过了,他们说不可能在其上放置id或可访问性标记,他们说是这种元素类型

我会通过x和y位置来做,但是如果我使用硬编码的数字,它会在不同分辨率的设备上中断

如何更有效地定位此元素

我使用appium进行测试自动化,但这对于任何测试自动化框架来说都是一个问题

图像中使用的工具是uiautomatorviewer


您应该尝试使用元素的类。
driver.findElement(By.className(“android.widget.EditText”)

如果出现超过1个元素,您可以尝试使用
List e=driver.findElements(By.className(“GLButton”);

e、 得到(≤位置>)。单击()

您应该尝试使用元素的类。
driver.findElement(By.className(“android.widget.EditText”)

如果出现超过1个元素,您可以尝试使用
List e=driver.findElements(By.className(“GLButton”);

e、 得到(≤位置>)。单击()

您可以在不硬编码值的情况下使用X&Y position,它也可以在其他设备上工作,因为“X”按钮没有定位器及其内置的edittext功能,所以android uiautomator无法访问此元素

  • 获取编辑文本的长度
  • 拿X&Y
  • 接触动作中的通过值(X的3/4,Y/2)

  • 这将单击该位置,在这里您需要根据您的位置更改3/4

    您可以使用X&Y位置,而无需硬编码该值,它也可以用于其他设备,因为“X”按钮没有定位器,其内置的edittext功能,所以安卓uiautomator无法访问该元素

  • 获取编辑文本的长度
  • 拿X&Y
  • 接触动作中的通过值(X的3/4,Y/2)

  • 这将单击该位置,您需要根据您的位置更改3/4。您可以使用Touchaction类点击editText字段中的交叉选项

    尝试使用下面的代码

    // 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();
    
    //标识EditText字段的x和y坐标
    Point elementLoc=driver.findElement(By.xpath(“edittext字段的xpath”)).getLocation();
    int eleX=elementLoc.getX();
    int eleY=elementLoc.getY();
    //标识editText字段的宽度和高度
    Dimension elementDimen=driver.findElement(By.xpath(“edittext字段的xpath”)).getSize();
    int eleH=elementDimen.getHeight();
    int eleW=elementDimen.getWidth();
    //确定交叉选项的x和y坐标
    int touchX=(int)(eleX+eleW*0.75D);//编辑文本字段x坐标的75%(交叉选项的x轴位置)
    int touchY=(int)(eleY+eleH*0.5D);//编辑文本字段y坐标的50%(交叉选项的y轴位置)
    //点击交叉选项
    TouchAction动作=新的TouchAction(驱动程序);
    点击(PointOption.point(touchX,toucy)).release().perform();
    

    在找到交叉选项的确切位置之前,先尝试touchX和touchY变量的偏移值。

    您可以使用Touchaction类在editText字段中点击交叉选项

    尝试使用下面的代码

    // 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();
    
    //标识EditText字段的x和y坐标
    Point elementLoc=driver.findElement(By.xpath(“edittext字段的xpath”)).getLocation();
    int eleX=elementLoc.getX();
    int eleY=elementLoc.getY();
    //标识editText字段的宽度和高度
    Dimension elementDimen=driver.findElement(By.xpath(“edittext字段的xpath”)).getSize();
    int eleH=elementDimen.getHeight();
    int eleW=elementDimen.getWidth();
    //确定交叉选项的x和y坐标
    int touchX=(int)(eleX+eleW*0.75D);//编辑文本字段x坐标的75%(交叉选项的x轴位置)
    int touchY=(int)(eleY+eleH*0.5D);//编辑文本字段y坐标的50%(交叉选项的y轴位置)
    //点击交叉选项
    TouchAction动作=新的TouchAction(驱动程序);
    点击(PointOption.point(touchX,toucy)).release().perform();
    

    在找到交叉选项的确切位置之前,先尝试touchX和touchY变量的偏移值。

    @Angusiasty这是什么?@Angusiasty我为问题添加了更多细节,这似乎不是自定义的view@Angusiasty那是什么?@Angusiasty我给问题添加了更多细节,这似乎不是我尝试的自定义视图,只得到1个元素,它有整个矩形,不返回XI尝试,只得到1个元素,它有整个矩形,不返回XWORD,检查如何分割X席,以便处理所有分辨率。感谢您检查我如何分割x位置,以便处理所有分辨率。thanksI在描述
    中明确表示,我会通过x和y位置执行此操作,但如果使用硬编码数字,则会在不同分辨率的设备上中断。
    我的问题是没有
    “edittext字段的xpath”
    对于元素…我在描述中清楚地说,我会通过x和y位置进行操作,但是如果我使用硬编码的数字,它会在具有不同分辨率的不同设备上中断。
    我的问题是元素没有
    “edittext字段的xpath”
    。。。。