Can someone please let me know how to remove the $
character displayed in the output list of the below code? Also, I want to add the sum of all the elements after removing. Please do needful.
public static void HHDollarAmoutValidation(){
try{
int AAWithclientTablecount = webDriver.findElements(By.xpath("//*[@id='DataTables_Table_21']/tbody/tr")).size();
System.out.println(AAWithclientTablecount);
String[] options=new String[AAWithclientTablecount];
List<String> optionsList=null;
for (int i=1; i<=AAWithclientTablecount; i++)
{
options[i-1] = webDriver.findElement(By.xpath("//*[@id='DataTables_Table_21']/tbody/tr["+ i + "]/td[8]")).getText();
System.out.println(options[i-1]);
optionsList = Arrays.asList(options);
}
System.out.println(optionsList);
}
catch(Exception e){
System.out.println(e);
}
}
Output:
[$3,171,349.51, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00, $0.00]