title: FindElement by XPath: nested divs/ classes
body: <p>I'm facing the problem with grabbing an element/ elements. I got list of products with "Amount" value, between that field there are two buttons: "-" and "+" which increases the total amount of that field.</p>
  
  <p>What I need to grab are both: plus or minus in order to test it correctly. I've already did it by css selector, however right now there is a need doing it by XPath.</p>
  
  <pre><code>var increaseIngredientButton = driver.FindElement(By.CssSelector(".product-ingredient-list &gt; div:nth-child(2) &gt; div:nth-child(3) &gt; div:nth-child(3)"));
  </code></pre>
  
  <p>And here is the HTML snippet: <a href="https://i.stack.imgur.com/n9zsQ.png" rel="nofollow noreferrer">Here</a></p>
  
  <p>First, I need to find the proper row - <strong>product-ingredient-row</strong> (there are many rows of specific products), differentiate it by it name - <strong>product ingredient-name</strong> (name is unique), and finally choose div with either plus or minus. Can someone tell me how it should be done because, unfortunately no idea...</p>
  
  <p>What's more, it's better to use XPath or Cssselectors? Is there a possibility to grab slightly everything with XPath? </p>
  
  <pre><code>&lt;div class="product-details-container"&gt;
     &lt;div class="product-details-header"&gt;
        &lt;div class="product-details-name"&gt;Berlusconi&lt;/div&gt;
        &lt;div class="product-details-price"&gt;
        &lt;/div&gt;
        &lt;div class="product-details-total-price"&gt;
           &lt;div&gt;Total: &lt;/div&gt;
           &lt;div&gt;
              &lt;!-- react-text: 3872 --&gt;11.90&lt;!-- /react-text --&gt;&lt;!-- react-text: 3873 --&gt; €&lt;!-- /react-text --&gt;
           &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="product-details-close"&gt;&lt;/span&gt;&lt;/div&gt;
     &lt;/div&gt;
     &lt;div class="product-details-scrollable-area"&gt;
        &lt;div class="product-details-allergenics"&gt;
           &lt;div&gt;Allergenics:&lt;/div&gt;
           &lt;div&gt;None&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="product-details-description-expander"&gt;
           &lt;div&gt;
              &lt;div style="padding-bottom: 0px;"&gt;
                 &lt;div style="padding: 16px; font-weight: 500; box-sizing: border-box; position: relative; white-space: nowrap; cursor: pointer;"&gt;
                    &lt;div style=&gt;&lt;span style="&gt;&lt;/span&gt;&lt;/div&gt;
                    &lt;button tabindex="0" type="button" style=&gt;
                       &lt;div&gt;
                          &lt;svg viewBox="0 0 24 24" style="&gt;
                             &lt;path d="M7.41 7.84L12 12.42l4.59-4.58L18 9.25l-6 6-6-6z"&gt;&lt;/path&gt;
                          &lt;/svg&gt;
                       &lt;/div&gt;
                    &lt;/button&gt;
                 &lt;/div&gt;
              &lt;/div&gt;
           &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="product-ingredient-row header"&gt;
           &lt;div class="product-ingredient-name"&gt;Ingredients:&lt;/div&gt;
           &lt;div class="product-ingredient-price"&gt;Unit price:&lt;/div&gt;
           &lt;div class="product-ingredient-quantity-container"&gt;Amount:&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="product-ingredient-list"&gt;
           &lt;div class="product-ingredient-row"&gt;
              &lt;div class="product-ingredient-name"&gt;Kotipizza-juusto&lt;/div&gt;
              &lt;div class="product-ingredient-price"&gt;
                 &lt;!-- react-text: 3908 --&gt;0.00&lt;!-- /react-text --&gt;&lt;!-- react-text: 3909 --&gt; €&lt;!-- /react-text --&gt;
              &lt;/div&gt;
              &lt;div class="product-ingredient-quantity-container"&gt;
                 &lt;div&gt;−&lt;/div&gt;
                 &lt;div&gt;1&lt;/div&gt;
                 &lt;div&gt;+&lt;/div&gt;
              &lt;/div&gt;
           &lt;/div&gt;
           &lt;div class="product-ingredient-row"&gt;
              &lt;div class="product-ingredient-name"&gt;tomaattikastike&lt;/div&gt;
              &lt;div class="product-ingredient-price"&gt;
                 &lt;!-- react-text: 3926 --&gt;0.00&lt;!-- /react-text --&gt;&lt;!-- react-text: 3927 --&gt; €&lt;!-- /react-text --&gt;
              &lt;/div&gt;
              &lt;div class="product-ingredient-quantity-container"&gt;
                 **&lt;div&gt;−&lt;/div&gt;
                 &lt;div&gt;1&lt;/div&gt;
                 &lt;div&gt;+&lt;/div&gt;**
              &lt;/div&gt;
           &lt;/div&gt;
           &lt;div class="product-ingredient-row"&gt;
              &lt;div class="product-ingredient-name"&gt;kantarelli&lt;/div&gt;
              &lt;div class="product-ingredient-price"&gt;
                 &lt;!-- react-text: 3962 --&gt;0.00&lt;!-- /react-text --&gt;&lt;!-- react-text: 3963 --&gt; €&lt;!-- /react-text --&gt;
              &lt;/div&gt;
              &lt;div class="product-ingredient-quantity-container"&gt;
                 &lt;div&gt;−&lt;/div&gt;
                 &lt;div&gt;1&lt;/div&gt;
                 &lt;div&gt;+&lt;/div&gt;
              &lt;/div&gt;
           &lt;/div&gt;
           &lt;div class="product-ingredient-row"&gt;
              &lt;div class="product-ingredient-name"&gt;savuporo&lt;/div&gt;
              &lt;div class="product-ingredient-price"&gt;
                 &lt;!-- react-text: 3971 --&gt;0.00&lt;!-- /react-text --&gt;&lt;!-- react-text: 3972 --&gt; €&lt;!-- /react-text --&gt;
              &lt;/div&gt;
              &lt;div class="product-ingredient-quantity-container"&gt;
                 &lt;div&gt;−&lt;/div&gt;
                 &lt;div&gt;1&lt;/div&gt;
                 &lt;div&gt;+&lt;/div&gt;
              &lt;/div&gt;
           &lt;/div&gt;
           &lt;div class="product-ingredient-row"&gt;
              &lt;div class="product-ingredient-name"&gt;punasipuli&lt;/div&gt;
              &lt;div class="product-ingredient-price"&gt;
                 &lt;!-- react-text: 3980 --&gt;0.00&lt;!-- /react-text --&gt;&lt;!-- react-text: 3981 --&gt; €&lt;!-- /react-text --&gt;
              &lt;/div&gt;
              &lt;div class="product-ingredient-quantity-container"&gt;
                 &lt;div&gt;−&lt;/div&gt;
                 &lt;div&gt;1&lt;/div&gt;
                 &lt;div&gt;+&lt;/div&gt;
              &lt;/div&gt;
           &lt;/div&gt;
           &lt;div class="product-ingredient-row"&gt;
              &lt;div class="product-ingredient-name"&gt;pizzapohja, runsaskuituinen&lt;/div&gt;
              &lt;div class="product-ingredient-price"&gt;
                 &lt;!-- react-text: 3989 --&gt;0.00&lt;!-- /react-text --&gt;&lt;!-- react-text: 3990 --&gt; €&lt;!-- /react-text --&gt;
              &lt;/div&gt;
              &lt;div class="product-ingredient-quantity-container"&gt;
                 &lt;div&gt;−&lt;/div&gt;
                 &lt;div&gt;1&lt;/div&gt;
                 &lt;div&gt;+&lt;/div&gt;
              &lt;/div&gt;
           &lt;/div&gt;
        &lt;/div&gt;
        &lt;button class="add-ingredient-btn" tabindex="0" type="button" style=&gt;
           &lt;div&gt;&lt;span style=&gt;Add Ingredient&lt;/span&gt;&lt;/div&gt;
        &lt;/button&gt;
     &lt;/div&gt;
     &lt;div class="product-details-actions"&gt;
        &lt;div style=&gt;
           &lt;button tabindex="0" type="button" style=&gt;
              &lt;div&gt;
                 &lt;div style=&gt;Add to cart&lt;/span&gt;&lt;/div&gt;
              &lt;/div&gt;
           &lt;/button&gt;
        &lt;/div&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>