selenium get parent element code example
Example 1: selenium get parent element python
input_el = driver.find_element_by_name('A')
td_p_input = input_el.find_element_by_xpath('..')
Example 2: retrieving parent element from child aWebelement selenium java
WebElement myElement = driver.findElement(By.id("myDiv"));
WebElement parent = (WebElement) ((JavascriptExecutor) driver).executeScript(
"return arguments[0].parentNode;", myElement);
Example 3: selenium select parent element
parent_element = element.find_element_by_xpath('./..')
Example 4: selenium get element parent
//label[contains(., 'labelName')]/parent::*//input[@value='elementToSelect']