0

I have a html code as

..

/div[2]/div[1]/ol/**li[1]**/header/div[2]
   ...

/div[2]/div[1]/ol/**li[2]**/header/div[2]
   ...

means two orderly listed items

So if i try searching for /div[2]/div[1]/ol/**li**/header/div[2], my selenium code says exists, but actually it doesn't. I think my selenium code is pointing out the headers in both of the listed items. How to fail the code if /div[2]/div[1]/ol/**li**/header/div[2] this doesn't exist.

Morvader
  • 2,317
  • 3
  • 31
  • 44
Joshi
  • 573
  • 3
  • 11
  • 24
  • Why you say the list doesnt exist?. If its in html code it does exist. You mean is not visible? – Morvader Jul 02 '14 at 08:03
  • list exists but there are 2 list items. xPath of the list is not correct. If u search for /div[2]/div[1]/ol/li/header/div[2] it should fail as only /div[2]/div[1]/ol/li[1]/header/div[2] or /div[2]/div[1]/ol/li[2]/header/div[2] exists – Joshi Jul 02 '14 at 08:08
  • 1
    Actually it **does exist**. In XPath, `.../li/...` without index means all `li` (both `../li[1]/..` & `../li[2]/..` in your example) – har07 Jul 02 '14 at 08:14
  • But how to make my selenium fail if it searches for /li/ when it has indexes in it like /li[1]/ or /li[2]/. Workaround that I have done here is if /li[2]/ exists means list of items are present. – Joshi Jul 02 '14 at 08:52
  • You need to post example of the page you are trying to target. – SiKing Jul 02 '14 at 16:55

0 Answers0