Created by
Hector Malpica
|
public void clickFromTitle(String title) {
String xpath = "//*[contains(text(), '" + title + "')]";
WebElement element = driver.findElement(By.xpath(xpath));
clickFromParentElement(element);
}
private void clickFromParentElement(WebElement element) {
WebElement parent = element.findElement(By.xpath(".."));
try {
WebElement button = parent.findElement(By.tagName("button"));
button.click();
} catch (NoSuchElementException e) {
clickFromParentElement(parent);
}
}
|