首页 > 解决方案 > 如何在java中将数组列表值存储在字符串中

问题描述

List<WebElement> Applicationfor = driver.findElements(By.xpath("//ul[contains(@id,'projectMainForm:projectTabSubview')]/li"));

// (I am capturing all the values that are there in the list with the above line)

List<String> applicationfor = new ArrayList<String>();

WebElement applicationfordropdown = driver.findElement(By.xpath("//td[normalize-

space()='Application For*']/following::div[contains(@class,'ui-selectonemenu-trigger')][1]"));

// (I am clicking on the dropdown and fetching the values which is assigned to the ArrayLIST)

applicationfordropdown.click();


 Applicationfor.forEach(Ele -> applicationfor.add(Ele.getText()));

//System.out.println("Print the colvalues:"+applicationfor);

 for(String text : applicationfor)
 {
    System.out.println("Print the lst values:"+text);
 }

我的问题是,如果将 applicationfor 值分配给数组列表,如上面的代码所示

仅打印列表中的第一个值。我哪里错了?

标签: java

解决方案


推荐阅读