选择复选框时,另一个元素文本在Appium中更改

时间:2017-09-22 05:37:43

标签: java selenium appium

我有一个元素,当我点击Element1时,另一个元素文本会添加一个数字“1”。如何验证当我点击元素时,数字会加起来。单击Element1,Element2,Element3和Apples编号加起来。你会如何在方法中编写脚本? Page oBjects = Viva_element = element。 Apple_Image =苹果的文字。这是正确的方法。

    Element1.     Apples 1
    Element2.     Apples 2 
    Element3      Apples 3
  public void selectingelements() {

    for(int index = 0; index < Viva_element.size(); index ++) {
        Viva_element.get(0).click();
        Assert.assertEquals(Apple_Image.getText(), "Apples (1)");
        APList.get(1).click();
        Assert.assertEquals(Apple_Image.getText(), "Apples (2)");
        APList.get(2).click();
        Assert.assertEquals(Apple_Image.getText(), "Apples (3)");
        APList.get(3).click();
        Assert.assertEquals(Apple_Image.getText(), "Apples (4)");


}

1 个答案:

答案 0 :(得分:0)

Following code will full fill your current requirement , please try once :

public void selectingelements() {

    for(int index = 1; index < Viva_element.size(); index ++) {
        Viva_element.get(index-1).click();
        Assert.assertEquals(Apple_Image.getText(), "Apples " + index);
    }

}