How to get the parent of an element in webdriver


<div class="field select-container invalid" data-tooltip="Error message." "name="birthDate">
<div class="stack-wrap gutter-col-wrap-1">
<div class="stack size1of3">
<div class="gutter-col-1">
    <div class="form-selectbox full-width">
    <select name="day">
        <option value="">Giorno</option>
        <option value="01">1</option>

When used WebElement el = browser.switchTo().activeElement(), the focus is on "name" attribute. Need to find the parent which is "data-tooltip" in order to get the error message on the screen. Please help.

Best Solution

For finding just parent of child element following code can be used.

IWebElement parentElement = childElement.FindElement(By.XPath(".."));