我有一个元素,当我单击Element1时,另一个元素文本加了一个数字“ 1”。当我单击元素时,如何验证数字相加。单击Element1,Element2,Element3和Apples编号相加。您将如何在方法中编写脚本。页面oBjects = Viva_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)");
}
最佳答案
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);
}
}
关于java - 选择复选框时,Appium中的另一个元素文本会更改,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46357536/