繁体   English   中英

带有Java的Selenium Webdriver(角度应用程序)

[英]Selenium Webdriver with Java (Angular application)

我已经编写了以下代码,用于从下拉列表中选择提及的值。
在这里,我只想从下拉列表中选择这些@data-option-array-index=1,3,5,9,28,34
我想使用一种将仅针对这些选定值运行的数组或循环。 但是我做不到

element=driver.findElement(By.xpath("//li[@class='search-field']"));
element.click();
element=driver.findElement(By.xpath("//li[@data-option-array-index='1']"));
element.click();
String text=driver.findElement(By.xpath("//li[@class='search-choice']")).getText();
System.out.println("Element text is: "+ text);

使用findElements,

List<WebElement> choises=driver.findElements(By.xpath("//li[@class='search-choice']"));
List<String> listValues= new Arraylist<String>();
for(WebElement choise : choises){
   listValues.add(choise.getText());
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM