title: Need to identify the ancestor of the mentioned web element
body: <p>New to Selenium. Been doing some activity but getting stuck every now and then.
  Plus if there is any error, at times it is not showing me the error. Below is my query.</p>
  <p>Address Book is a page that stores address.</p>
  <p>URL: <a href="http://webapps.tekstac.com/AddressBook/" rel="nofollow noreferrer">http://webapps.tekstac.com/AddressBook/</a></p>
  <p>This is the procedure:
  Invoke the driver using getWebDriver() method defined in DriverSetup().
  Navigate to &quot;http://webapps.tekstac.com/AddressBook/&quot;.
  Identify ancestor of the 'Nick Name' label text. That is the ancestor 'div' of the form. Get the text of this ancestor  and store it in a static variable fName.</p>
  <p>This is the code for which I am 66.67% evaluated.</p>
  <pre><code>import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebElement;
  import java.util.concurrent.TimeUnit;
  
  public class NameLocator      //DO NOT Change the class name
  {
      //Use the declared variables for stroing required values
      static String fName;
      static String baseUrl;
      static WebDriver driver;
      
      
      public WebDriver setupDriver()           //DO NOT Change the method Signature
      {
          DriverSetup ds = new DriverSetup();
          return ds.getWebDriver();
          /* Replace this comment by the code statement to create and return the driver */
          /* Naviaget to the url 'http://webapps.tekstac.com/AddressBook/'  */
          
      }
      public String getNameLocator()              //DO NOT Change the method Signature
      {
          WebElement element = driver.findElement(By.xpath(&quot;//div[.//[text()='NickName']]/ancestor::div&quot;));
          fName = element.getText();
          driver.close();
          return fName;
         /*Using the driver, Find the element ancestor and its text and assign the text to 'fName' */
         /*Close the driver*/
        
        
      }
      
      public static void main(String[] args)
      {
          NameLocator namLocator=new NameLocator();
          //Add required code here
      }
  
  }
  </code></pre>
  <p>Error while compiling: Ancestor's div text is not correct.</p>
  <p>THIS IS HOW THE ORIGINAL TEMPLATE LOOKED BEFORE I STARTED FILLING UP THE CODE. THIS IS HOW THEY HAVE DESIGNED THE ACTIVITY AND THE COMMENTS WERE NOT MANUALLY ENTERED BY ME.</p>
  <pre><code>import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebElement;
  import java.util.concurrent.TimeUnit;
  
  public class NameLocator      //DO NOT Change the class name
  {
      //Use the declared variables for stroing required values
      static String fName;
      static WebDriver driver;
      
      public WebDriver setupDriver()           //DO NOT Change the method Signature
      {
          /* Replace this comment by the code statement to create and return the driver */
          /* Naviaget to the url 'http://webapps.tekstac.com/AddressBook/'  */
          
      }
      public String getNameLocator()              //DO NOT Change the method Signature
      {
         /*Using the driver, Find the element ancestor and its text and assign the text to 'fName' */
         /*Close the driver*/
        
      }
      
      public static void main(String[] args)
      {
          NameLocator namLocator=new NameLocator();
          //Add required code here
      }
  
  }
  </code></pre>