0

Application developed in salesforce and below is the code for an dropdown box, all the items in the drop down they build with <li> tag, but i dont know how to pick a particular item with this design

<div id="Department__cformControl" class="slds-form-element">
    <div id="Department__c" class="slds-picklist" data-aljs="picklist" aria-expanded="true">
        <button class="slds-button slds-button--neutral slds-picklist__label cusPicklistBtn" aria-haspopup="true">
            <span class="slds-truncate">
                None
            </span>
            <svg class="slds-icon" aria-hidden="true">
                <use xlink:href="/resource/1475922714000/slds/assets/icons/utility-sprite/svg/symbols.svg#down"></use>
            </svg>
        </button>
        <div class="slds-dropdown slds-dropdown--left slds-dropdown--menu slds-hide">
            <ul class="slds-dropdown__list" role="menu">
                <li id="menu0" class="slds-dropdown__item slds-is-selected" href="#"> … </li>
                    <a role="menuitemradio" href="javascript:void(0)">
                        <p class="slds-truncate">
                            <svg class="slds-icon slds-icon--selected slds-icon--x-small slds-icon-text-default slds-m-right--x-small" aria-hidden="true">
                                <use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#check" xmlns:xlink="http://www.w3.org/1999/xlink"></use>
                            </svg>
                        Information Technology
                        </p>
                    </a>
                </li>
                <li id="menu1" class="slds-dropdown__item" href="#"> … </li>
            </ul>
        </div>
    </div>
</div>

my expected : i want to choose the item Information Technology

in the normal drop down i can easily choose the item using select e.g :new Select(sourceDropDown).selectByVisibleText(Value);

but please clarify how can i choose the item?

1

Don't know if you found the solution and here is how I solved it. It basically involves 2 clicks.

  1. Click on the <a> element to bring the list of <li> options to be visible
  2. Click on <li> element to pick the value

    WebElement element = driver.findElement(By.xpath("//div//a[@class='select']"));
    JavascriptExecutor executor = (JavascriptExecutor) driver;
    executor.executeScript("arguments[0].click();", element);
    
    
    WebElement element1 = driver.findElement(By.xpath("//ul/li/a[text()='Costco']"));
    executor.executeScript("arguments[0].click();", element1);
    
| improve this answer | |
-1
Select sel = new Select(driver.findElement(By.*locator*("")));
sel.SelectByVisibleText("Information Technology");
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.