0

How to click the icon in a split button in order to see the drop down list in the following UI code.

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

Here is my codes. The drop-down list doesn't seem to show.
In NetworkPageObject.java file:

@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;
}

In NetworkTest.java file:

@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();  
    */
Liddy
  • 1
  • 2
  • My guess is that your XPath is not specific enough. Try `driver.findElements(By.xpath("//*[starts-with(@id, 'splitbutton')]/descendant::span[contains(text(),'Estimate')]")).size()` to see how many there are. – SiKing Jul 11 '14 at 21:17
  • There is 1 matching node. – Liddy Jul 11 '14 at 21:33
  • If you remove the `@CacheLookup`, does anything change? What exactly do you mean by "The drop-down list doesn't seem to show."? Is there an error? – SiKing Jul 11 '14 at 21:36
  • The drop down list will show only when user click right-edge of split button. I have tried to specify xpath to , but still no luck. 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 ')]") // Also only 1 match node for both xpath listed above. – Liddy Jul 11 '14 at 21:38
  • Is the site, or at least an example of this button, somewhere publicly available? – SiKing Jul 11 '14 at 21:45
  • remove the @CacheLookup doesn't seem to change anything. I expect when I click the drop down arrow, the drop down menu will show. However, I don't see that drop down list/menu showed. No error is threw. – Liddy Jul 11 '14 at 21:48
  • There is no publicly available site. I cannot add image here, but I found am example of the button. Please see screenshot.jpeg in this link. https://code.google.com/p/selenium/issues/detail?id=5700 – Liddy Jul 11 '14 at 21:57
  • So it's an extjs control. I am not familiar with those, but have a look at this: http://stackoverflow.com/a/219506/3124333 – SiKing Jul 11 '14 at 22:00
  • okie. Thank you SiKing – Liddy Jul 11 '14 at 22:23
  • @SiKing. I found the solution - Instead of using SplitButton in UI code, use normal Ext.Button with a menu. i.e. – Liddy Jul 11 '14 at 23:55
  • – Liddy Jul 11 '14 at 23:58

0 Answers0