0

In Sales force application. All the elements doesn't have proper and static id or name or other properties.

My requirement is to get all the values from a dropdownlist on salesforce web-app.

CSS showing on inspecting dropdownlist on chrome browser:

<div data-aura-rendered-by="9529:0"><a aria-required="false" class="select" aria-disabled="false" aria-describedby="9520:0-label" aria-haspopup="true" tabindex="0" role="button" title="" data-aura-rendered-by="9530:0" href="javascript:void(0);" data-interactive-lib-uid="10">--None--</a></div>'

It is only showing already selected value . i.e. None by default in my application.

I am not able to see the other options in this div.This doesn't help me to get values. On inspecting the values inside the dropdown list, it is showing html on some other location

<div class="select-options" role="menu" data-aura-rendered-by="9542:0"><!--render facet: 9543:0--><ul class="scrollable" role="presentation" data-aura-rendered-by="9544:0"><!--render facet: 10751:0--><li role="presentation" data-aura-rendered-by="10755:0" class="uiMenuItem uiRadioMenuItem" data-aura-class="uiMenuItem uiRadioMenuItem"><a data-aura-rendered-by="10756:0" href="javascript:void(0);" role="menuitemradio" aria-disabled="false" tabindex="0" title="--None--" aria-checked="false"><b></b>--None--</a></li><li role="presentation" data-aura-rendered-by="10761:0" class="uiMenuItem uiRadioMenuItem" data-aura-class="uiMenuItem uiRadioMenuItem"><a data-aura-rendered-by="10762:0" href="javascript:void(0);" role="menuitemradio" aria-disabled="false" tabindex="0" title="Provider Concern / Question" aria-checked="false"><b></b>Provider Concern / Question</a></li><li role="presentation" data-aura-rendered-by="10767:0" class="uiMenuItem uiRadioMenuItem" data-aura-class="uiMenuItem uiRadioMenuItem"><a data-aura-rendered-by="10768:0" href="javascript:void(0);" role="menuitemradio" aria-disabled="false" tabindex="0" title="Provider No Show" aria-checked="false"><b></b>Provider No Show</a></li></ul></div>

I tried to use the below code to retrieve values. but only getting empty values:

List<WebElement> subStatuses = driver.findElements(By.xpath("(.//div[@class='select-options popupTargetContainer uiPopupTarget uiMenuList uiMenuList--default uiMenuList--left uiMenuList--short'])[3]//li"));      
        System.out.println("size of the data list :: "+subStatuses.size()+"values:: "+subStatuses.toString());              
        for(WebElement e:subStatuses)
        {
            System.out.println("Values from Fsl dropdownlist"+e.getText().toString());
        }

Any help on how to retrieve values from this drop down is appreciated..!

6
  • Post the relevant HTML of the "fake" SELECT and properly format your code as code. If you need help with that, edit your question and see the formatting help link inside. Commented Oct 3, 2018 at 22:13
  • @Vijay When you are not getting values that means Your XPath is incorrect, Please post relevant HTML Code. so we can get proper XPath or any other tags. Commented Oct 4, 2018 at 6:32
  • what is the size of Data List? Commented Oct 4, 2018 at 7:00
  • Edit the HTML into your question so it can be properly formatted and more easily read. You generally don't want to put important info in comments. It makes future readers have to read all comments to get all the relevant info to understanding and answering a question. Instead, edit your question and put all the relevant info there and then if you need to notify someone you responded to their comment, just @ them and comment that you edit your question with their requested info, etc. Commented Oct 4, 2018 at 17:31
  • updated in the question per the suggestion...! Commented Oct 4, 2018 at 17:50

1 Answer 1

1

Your xpath seems to be wrong: Try something like that:

List<WebElement> subStatuses = driver.findElements(By.xpath("//div[@class='select-options']/ul/li[contains(@class, 'uiMenuItem')]/a"));

That should work if it's the only "select" on your page. If there is more than one you might need to specify which select-options-div in the dom you want e.g. selecting the first occurrence: //div[@class='select-options'][1]/ul/li[contains(@class, 'uiMenuItem')]/a and instead of getText(); you might have to use element.getAttribute('textContent');

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.