public By idReturn(String id){
id = id.toLowerCase();
if(id.startsWith("id~")) return By.id(id.replace("id~", ""));
else if(id.startsWith("name~")) return By.name(id.replace("name~", ""));
else if(id.startsWith("cssselector~")) return By.cssSelector(id.replace("cssselector~", ""));
else if(id.startsWith("xpath~")) return By.xpath(id.replace("xpath~", ""));
return By.xpath("Unable to find the element locater");
}
public boolean enterText(String id, String value){
if(value.length() == 0) return false;
driver.findElement(idReturn(id)).clear();
driver.findElement(idReturn(id)).sendKeys(value);
return true;
}
public void clickElement(String id){
driver.findElement(idReturn(id)).click();
}
id = id.toLowerCase();
if(id.startsWith("id~")) return By.id(id.replace("id~", ""));
else if(id.startsWith("name~")) return By.name(id.replace("name~", ""));
else if(id.startsWith("cssselector~")) return By.cssSelector(id.replace("cssselector~", ""));
else if(id.startsWith("xpath~")) return By.xpath(id.replace("xpath~", ""));
return By.xpath("Unable to find the element locater");
}
public boolean enterText(String id, String value){
if(value.length() == 0) return false;
driver.findElement(idReturn(id)).clear();
driver.findElement(idReturn(id)).sendKeys(value);
return true;
}
public void clickElement(String id){
driver.findElement(idReturn(id)).click();
}