title: Selecting a parent of a child element using XPath
body: <p>Before I start in the source code I have included in this post I have replaced any sensitive data with a string of &quot;x&quot;.</p>
  <pre><code>&lt;div class=&quot;pod productPod icon-life clearFix nonwrap&quot;
       id=&quot;xxxxxxxxxx&quot;
       internalid=&quot;xxxxxxxxxx&quot;
       data-properties-type=&quot;xxxxxxxxxx&quot;
       data-properties-code=&quot;xxxxxxxxxx&quot;
       data-properties-loaded=&quot;False&quot;
       data-properties-url=&quot;xxxxxxxxxx&quot;
       data-properties-showmaintenanceerrormessage=&quot;False&quot;
       data-properties-product-type=&quot;xxxxxxxxxx&quot;&gt;
    &lt;span class=&quot;podTitle&quot;&gt;Your policies&lt;/span&gt;
    &lt;div id=&quot;1&quot; class=&quot;productPodInner&quot; data-qa-productpod=&quot;&quot;&gt;
      &lt;span class=&quot;notificationBubble fullProdLarge&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;
      &lt;h2&gt;&lt;a data-feedback=&quot;&quot; class=&quot;clearFix roundelLink&quot; href=&quot;#productId0&quot; data-roundel-id=&quot;0&quot;&gt;
        &lt;span class=&quot;productIconWrapper&quot;&gt;
          &lt;span class=&quot;productIcon&quot;&gt;
          &lt;/span&gt;
        &lt;/span&gt;
        &lt;span class=&quot;productData&quot;&gt;
          &lt;span class=&quot;productName&quot; style=&quot;min-height: auto;&quot;&gt;Protection&lt;/span&gt;
          &lt;span class=&quot;notificationBubble fullProd&quot;&gt;&lt;/span&gt;
        &lt;/span&gt;
      &lt;/a&gt;&lt;/h2&gt;
  
      &lt;div class=&quot;productDetails podContent&quot; id=&quot;#productId0&quot; style=&quot;width: 1903px; left: -306.703px;&quot;&gt;
        &lt;div class=&quot;productDetailsInner clearFix&quot;&gt;
          &lt;h3&gt;xxxxxxxxxx&lt;/h3&gt;
          &lt;!-- TODO:: Display this in the 2nd column--&gt;
          &lt;dl class=&quot;initialPolicyContainer detailsList&quot; style=&quot;display: none;&quot;&gt;
            &lt;dt&gt;Policy Number&lt;/dt&gt;
            &lt;dd class=&quot;initialPolicyNumber&quot; data-qa-text=&quot;xxxxxxxxxx&quot;&gt;xxxxxxxxxx&lt;/dd&gt;
          &lt;/dl&gt;
          &lt;div class=&quot;clearFix variant3Container&quot; style=&quot;&quot;&gt;&lt;div class=&quot;group-1-2 clearFix&quot;&gt;
            &lt;div class=&quot;column&quot;&gt;
              &lt;dl class=&quot;detailsList&quot;&gt;
                &lt;dt&gt;Policy number&lt;/dt&gt;
                &lt;dd class=&quot;policyNumberVal&quot;&gt;xxxxxxxxxx&lt;/dd&gt;
                &lt;dt&gt;Term&lt;/dt&gt;
                &lt;dd&gt;xxxxxxxxxx&lt;/dd&gt;
              &lt;/dl&gt;
  </code></pre>
  <p>So my goal here is to be able to select the top parent  using an Xpath locator and then click on that  with selenium.</p>
  <p>On the website there is a pod with multiple roundel sections each containing its own policy. Normally I can select a roundel using an Xpath query that finds the roundel by the policyType(text) but if there are 2 policies with the same policyType then this Xpath locator will only find the first one.</p>
  <p>Roundel has a unique policyNumberVal (line 29)</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;dd class="policyNumberVal"&gt;xxxxxxxxxx&lt;/dd&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>That I can locate using this Xpath:</p>
  <blockquote>
  <p>//dd[@class='policyNumberVal' and text() = '{policyNumber}']</p>
  </blockquote>
  <p>What I could like to know is, once I have located the 'policyNumberVal' how do I then step up and select the parent ?</p>
  <p>Please let me know if you need any more information than this.</p>