java - Why I must search explicitly relative elements in Selenium by xpath? -
i'm trying elements xpath selenium's webdriver:
webelement element1 = driver.findelement(by.id("someid")); list<webelement> xpathelements = element1.findelements((by.xpath("//span[@class='someclass']")));
with code, i'm getting elements class='someclass' in dom.
only when add "." @ beginning of xpath string elements class='someclass' under element1
element1.findelements((by.xpath(".//span[@class='someclass']")));
what's sense here? called findelements
element1
default should search elements under element1
, why must add "."?
it has got nothing selenium, way xpath works.
if have //elem xpath located anywhere in document. if want search element relative element or rather descendant have use '.' or dot .//elem.
Comments
Post a Comment