2

I am trying to select a value from a dropdown. When I inspect that dropdown, I cannot see the select Tag, instead it was designed with combination of input and div tags.

Can anyone suggest a way how to automate it using selenium webdriver (Java)?

enter image description here

There is no visible text even. When I tried to select it through value attribute, I can see the value attribute in inspect is still showing "none". I mean to say even after selecting any item from dropdown manually, I thought that text would reflect in value attribute, but that didn't happen. Value attribute is always showing "none". Is there any other way to select the value from this dropdown?

HTML for the input is

<input id="Claimant_Picker-inputEl" data-ref="inputEl" type="text" role="combobox" size="1" name="Claimant_Picker" value="<none>" style="width:100%;" class="x-form-field x-form-text x-form-text-default " autocomplete="off" componentid="NewClaimVehicleDamageDV:Claimant_Picker"> 

Html for the div is

<div id="Claimant_Picker-trigger-picker" class="x-form-trigger x-form-trigger-default x-form-arrow-trigger x-form-arrow-trigger-default ">
</div>
4
  • So how are the dropdown options looking in HTML?
    – FDM
    Nov 29, 2018 at 9:43
  • 1
    I believe when you expand your drop down your DOM gets changed. Can you capture the drop down items in your dev tools when the drop down is expanded?
    – Alexey R.
    Nov 29, 2018 at 11:33
  • @FDM : Unable to inspect the dropdown options at all. Those are hidden. When I tried to right click on dropdown options , it's not working. Dec 24, 2018 at 12:35
  • @AlexeyR. Yes , When I expand my dropdown DOM is getting changed , I tried to capture the dropdown options using Value attribute of the input tag which I shared earlier, but that didn't work. Dec 24, 2018 at 12:37

2 Answers 2

1

I think the developers of the site are using a Front-end UI Framework. From the partial code, I could not detect which framework. Most modern UI frameworks do not use select-tags, but smart javascript to change the DOM on the fly. The options are probably somewhere in a JavaScript variable in memory.

The framework probably does a lot of magic when you select the input. I would consult the developers to figure out how the input select works. This will probably enlighten you how to test it or give you more information to search because you know which framework is used. Most frameworks have extra testing libraries to make testing their implementation easier.

-1

Your question is bit complicated can we see How you select a value from dropdown. Even I cant see You can select your dropdown by value,text,index etc.
Below is the code that I commonly use when I have to handle drop-downs.

//select the dropdown using "select by visible text"
        public static void dropDownSelectByText(WebElement webElement, String VisibleText){
            Select selObj=new Select(webElement);
            selObj.selectByVisibleText(VisibleText);
        }

        //select the dropdown using "select by index"
        public static void dropDownSelectByIndex(WebElement webElement, int IndexValue){
            Select selObj=new Select(webElement);
            selObj.selectByIndex(IndexValue);
        }

        //select the dropdown using "select by value"
        public static void dropDownSelectByValue(WebElement webElement, String Value){
            Select selObj=new Select(webElement);
            selObj.selectByValue(Value);
        }

You can pass values like this

CommonPageOperations.dropDownSelectByText(clientDrpDownListXpath,strClientName);
2
  • This unfortunately is not going to work if there is no <select> element on the page.
    – Kate Paulk
    Nov 30, 2018 at 12:52
  • There is no 'select' tag in the HTML code. If there is any other way to select the value from dropdowns , please post it. Dec 24, 2018 at 12:38

Your Answer

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

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