1
<div class="languageContainer">
  <p class="flag fltlft" style="margin-right: 20px;">
    <a class="color4 engflag-in lang01 notranslate active" href="#" data-placement="0" data-lang="English">English</a>
  </p>
  <p class="flag fltlft">
    <a class="color4 lang01 notranslate spanishflag-in current" href="#" data-placement="3" data-lang="Spanish">Español</a>
  </p>
</div>

Using XPath //div[@class='languageContainer']/p/a. We are able to locate both the links. I need to verify the order of both the elements using verifyordered. But when I verify using verifyOrdered in Selenium IDE like this:

verifyOrdered | //div[@class='languageContainer']/p/a[text()="English"] | //div[@class='languageContainer']/p/a[text()="Español"]

Gives an [error] false in the log.

Even though the next element of English like is Espanol according our XPath. The verification fails. Can someone please me on this?

user1
  • 945
  • 2
  • 13
  • 37
Melvin Richard
  • 403
  • 1
  • 7
  • 15

1 Answers1

0

I think the problem is that you're going to far down the dom. The A elements are not the siblings of the same parents. you actually need to find the two P s (with class "flag fltlft")

So this would work:

<tr>
    <td>verifyOrdered</td>
    <td>//div[@class='languageContainer']/p[1]</td>
    <td>//div[@class='languageContainer']/p[2]</td>
</tr>

But that's obvious: because of the index's [1] & [2]. So to do that we need to select the P tags that have the children A tags we want. The change is subtle:

<tr>
    <td>verifyOrdered</td>
    <td>//div[@class='languageContainer']/p[a[text()=&quot;English&quot;]]</td>
    <td>//div[@class='languageContainer']/p[a[text()=&quot;Español&quot;]]</td>
</tr>

But if you use the IDE highlighter you'll see you're now selecting the P tags & not the A tags and verifyOrdered will now work for you!

FYI -> More info on selecting an element based on a child can be found herE: XPath to select element based on childs child value

Community
  • 1
  • 1
DMart
  • 2,401
  • 1
  • 14
  • 19
  • That gave a good clarity. Thanks.. I found another way around for verifying the order of the element by using css locator. I just want to share it. verifyText css=.color4.lang01.notranslate:nth(0) English verifyText css=.color4.lang01.notranslate:nth(1) Español Thanks for your answer again. – Melvin Richard Nov 24 '15 at 05:40
  • yup, that works. So could the xpath as I kind of indicated in the top response. Glad to help. – DMart Nov 24 '15 at 15:05