This is the salesforce application, i want to click the admin menu, so below is the source
<li class="slds-context-bar__item slds-shrink-none" is="one-app-nav-bar-item-root">
<a class="slds-context-bar__label-action" href="#/n/admin" title="Admin" tabindex="0">
<span class="slds-truncate">Admin</span>
</a>
</li>
i framed below xpath using contains, but its not working
driver.findElement(By.xpath("//span[contains(.,'Admin')]"));
I get the path from firepath/IDE, its working
@FindBy(how =How.XPATH, using = "//header[@id='oneHeader']/div[3]/one-appnav/div/one-app-nav-bar/nav/ul/li[2]/a/span")
but i want to frame generic xpath with above html either using menu name or title (admin), please guid me, because in feature if any ul or li tag added in between its not working
当您尝试将带有文本的节点标识为Admin
,可以使用以下代码行:
driver.findElement(By.xpath("//a[@class='slds-context-bar__label-action' and @title='Admin']/span[@class='slds-truncate']"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.