1

I am trying to find the xpath of the element below, so that I can later get the text using Ruby Selenium-webdriver (ie. helloPage.mainHeader.get_text).

<div class="container">
  <div class="template-section">
    <div class="front">
      <h3 class="containerHeading">
      <i class="icon_image"></i>
      "Hello world   <-----------------------3 whitespaces
      "
      </h3>
    </div>
   </div>
</div>

I've worked on xpaths but everytime I rerun the test it timesout essentially the element does not exist. It is clearly visible on the UI and not hidden.

Why is my xpath is wrong? I have tried the following:

  1. //div[@class='container']//div[@class='template-section']//div[@class='front']//h3[@class='containerHeading']
  2. //div[@class='front']//h3[@class='containerHeading']
  3. //h3[@class='containerHeading']

I did put sleep prior to executing helloPage.mainHeader.get_text, where mainHeader has the XPath expression, and that didn't work. Is there something mysterious about the Hello World text? The format is indeed like the way I typed it out.

4

1 に答える 1