Reputation: 433
This works fine
driver.findElement(By.xpath("//span[@id='dummyid' or @class='man-add']"));
But and operator is not working.
driver.findElement(By.xpath("//span[@id='dummyid' and @class='man-add']"));
driver.findElement(By.xpath("//span[@id='dummyid' | @class='man-add']"));
Upvotes: 3
Views: 22437
Reputation: 9570
You can't use |
for a logical-or, you need to use or
. You can indeed use and
for logical-and (but of course not &
). You didn't supply the HTML you're trying to run this against, so we can only guess, but based on experience I'd assume the class
attribute has more than just man-add
in it. If so, you want something more like //span[@id='dummyid' and contains(@class, 'man-add')]
.
Upvotes: 10