按照下面的过程:
- 获取各元素的下拉文本(“选项”的元件)以列表或字符串的数组
- Strote的值。
- 查看列表或数组包含您的姓名&邮件id值。
或者如果u只想要断言,然后在换每个数组或列表的循环: 添加牛逼
- 他断言在try-catch块的语句。
- 在catch块中,每次执行到这个块时,增加一个整数。
- 经过fr-each循环后,检查整数值是否等于yor列表或数组大小。
的第一个场景代码示例:
driver.findElement(By.cssSelector(".trb_outfit_sponsorship_logo_img"))
.click();
System.out.println(dri.findElement(
By.cssSelector(".trb_outfit_sponsorship_logo_img")).getSize());
List<WebElement> dropDownValues = dri.findElements(By
.xpath("//select[@id='Customer']"));
ArrayList<String> dropDownValuesasText = null;
for (WebElement eachValue : dropDownValues) {
dropDownValuesasText.add(eachValue.getText());
}
// boolean result = dropDownValuesasText.contains("Your FirstName & Email value");
//It will pass if your value is present in drop down
assertNotEquals(dropDownValuesasText.contains("Your FirstName & Email value"), true);
感谢您的快速回复,你能为我提供的脚本来实现这个...... –
更新了答案 – HemaSundar