Snippets

Hector Malpica exemple.java

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);
		}
	}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.