如何单击拆分按钮中的图标以查看以下 UI 代码中的下拉列表。
<div id="splitbutton-1081" class="x-btn x-box-item x-btn-default-small x-noicon x-btn-noicon x-btn-default-small-noicon x-menu-active x-btn-menu-active x-btn-default-small-menu-active x-over x-btn-over x-btn-default-small-over over" style="margin: 0px; padding: 2px 10px; background-color: rgb(109, 172, 236); background-image: none; border: 1px solid rgb(36, 91, 147) ! important; left: 474px; top: 0px;">
<em id="splitbutton-1081-btnWrap" class="x-btn-split x-btn-split-right">
<button id="splitbutton-1081-btnEl" class="x-btn-center" autocomplete="off" role="button" hidefocus="true" type="button" style="height: 16px;">
<span id="splitbutton-1081-btnInnerEl" class="x-btn-inner" style="">Estimate</span>
<span id="splitbutton-1081-btnIconEl" class="x-btn-icon "/>
</button>
</em>
</div>
这是我的代码。下拉列表似乎没有显示。
在 NetworkPageObject.java 文件中:
@FindBy(xpath = "//*[starts-with(@id, 'splitbutton')]/descendant::span[contains(text(),'Estimate')]")
@CacheLookup
private WebElement EstimateDropList;
/* I also tried 2 different xpath as follows, but drop-down list still not show. i.e.
@FindBy(xpath = "//*[starts-with(@id, 'splitbutton')]/descendant::span[contains(text(),'Estimate')]/following-sibling::span[@class='x-btn-icon '][1]")
@FindBy(xpath = "//*[starts-with(@id, 'splitbutton')]/descendant::span[contains(@class, 'x-btn-icon ')]")
*/
public void click_EstimateDropList() {
ExpectedConditions.visibilityOf(EstimateDropList);
EstimateDropList.click();
public WebElement get_EstimateDropList() {
return EstimateDropList;
}
在 NetworkTest.java 文件中:
@Test(description="Test if user can click Estimate drop list")
public void testClickNetworkEstimate () {
NetworkPageObject networkPageObj =PageFactory.initElements(driver,
NetworkPageObject.class);
networkPageObj.click_EstimateDropList();
/* I also tried the following, but no drop-down will show
Actions build = new Actions(driver);
build.moveToElement(networkPageObj.get_EstimateDropList())
.release(networkPageObj.get_EstimateDropList()).build().perform();
*/