xpath get element by index
In XPath index starts from 1 position, therefore
//div[@class="post-content"]//img[2]
should work correctly if you have to select each 2nd img
in div[@class="post-content"]
.
If you want to select only 2nd img
from all images that are in div[@class="post-content"]
, use:
(//div[@class="post-content"]//img)[2]
indexes in XPath are 1-based, not 0-based. Try
(//div[@class="post-content"]//img)[position()=2]