我的 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>