Hi
I am trying to remove the first and last charater of each element of string list so I can pass the string inside xpath since I am getting data from listed table it always add [] to the name example: [Selenium]
Since I have string list I was able to remove the first "[" but I can't use lenght -1 to remove the last "]"
public void iAddAffiliatesWithName( DataTable dataTable) {
SimpleAction.runs(() -> {
List<String> Orgs = dataTable.asList(String.class);
String Org1 = StringUtils.substring(String.valueOf(Orgs), 1, 11);
//I need to be able to use lenght instead 11System.out.println(">>>>>This is org1 >>: " + Org1);
// String urlResdesk = GlobalProperties.INSTANCE.getRegionProperty(PKEnvVariable.URL_RESDESK.getPropertyName());
String urlResdesk = ActionType.GetValueFromUrl.getWebDriver().getCurrentUrl();
System.out.println(">>>>>: " + urlResdesk);
if (urlResdesk.contains("hotel")){
for(int i=0;i<Orgs.size();i++) {
Input.run(Passkey_Events.PK_Hotel_PlannersAndAffiliates.lblClickHere);
Input.run(Passkey_Events.PK_Hotel_PlannersAndAffiliates.btnAffiliateLookup);
ActionType.SwitchTo.run(String.valueOf("1"));
Input.run(Passkey_Events.PK_Hotel_PlannersAndAffiliates.txtAffiliatesByName, Orgs.get(i));
Input.run(Passkey_Events.PK_Hotel_PlannersAndAffiliates.btnSearchAfiliattes);
Input.run(Passkey_Events.PK_Hotel_PlannersAndAffiliates.chkAffiliates);
Input.run(Passkey_Events.PK_Hotel_PlannersAndAffiliates.btnAddSelectedAffiliates);
ActionType.SwitchTo.run(String.valueOf("0"));
System.out.println(">>>> Org is :" + Org1);
// VerifyExistence.run(By.xpath("(//a[contains(.,'" + Orgs +"')])[1]"));
// VerifyExistence.run(By.xpath(" (//a[contains(.,'!Eric API')])[1]"));
}
} else {
System.out.println(">>>>> no hotel found");
}
});
}
}
Thanks
Instructor
Ashish Thakur Replied on 28/10/2020
As I could understand that
Suppose you have a list - ["A","B ","C","D"]
You want to remove A and D from this java list?