我的XPath是:
無法找到動態的XPath
// * [@ ID = 'form_MenuBar:j_id24']/SPAN
和值#24的變化。
// * [@ ID = 'form_MenuBar:j_id48']/SPAN
我試過,但沒有作品。
driver.findElement(By.xpath(「// a [contains(@ id,'form_MenuBar:j_id $')]/span」));
源XML:
<li class="ui-menuitem ui-widget ui-corner-all ui-menuitem-active" role="menuitem">
<a id="form_MenuBar:j_id24" class="ui-menuitem-link ui-corner-all ui-state-hover" href="/Demand/j_spring_security_logout">
<span class="ui-menuitem-text">Log off</span>
</a>
</li>
你可以發佈你正在尋找的元素的HTML嗎?另外,你是否嘗試過使用'form_MenuBar:j_id'?使用xpath時某些符號會導致問題。 – Nashibukasan 2013-02-11 04:52:49