Unable to select multiple values from dropdown for multi-select field

Hi Team,
I am facing an issue while selecting multiple values from the dropdown list for the multi-select field
The keyword selects the first few values from the dropdown but after that instead of clicking on the dropdown list the control goes to the already selected list value and dropdown is not seen.
Please help me find a solution
Please refer screenshot

Code:
Enter Cipher text
${field_name} Set Variable //[@id=‘cipher-list’]
Wait Until Element Is Visible ${field_name}
click element ${field_name}
sleep 1s
${names} = Create List TLS_CHACHA20_POLY1305_SHA256 TLS_AES_128_CCM_SHA256 TLS_AES_256_GCM_SHA384
FOR ${list_name} IN @{names}
sleep 1s
Input Text //
[@class=‘oj-listbox-search-wrapper’]//input ${list_name}
click element //*[@class=‘oj-listbox-results’]
sleep 1s
Scroll Element Into View ${field_name}
click element ${field_name}
END
Click OK Button

Hi Madhurya,

Well lets get the bad news out of the way first, those multi-select searchable drop-down’s in your screen shots are not standard HTML, they are something custom, so neither SeleniumLibrary, no Browser Library are going to have keywords for them (I’m guessing you are using SeleniumLibrary?), so there’s no easy quick answer.

Now for some good news, I did a quick search for “oj-listbox-search-wrapper” and found oj.common.formcontrol.listbox, which tells me the UI is built using the Oracle JavaScript Extension Toolkit (JET) framework, this means you can at least expect all these type of fields to be very similar and behave the same ways throughout your application.

I don’t know anything about Oracle JET, or more specifically it’s listbox. perhaps there’s a limit to the number of items you can select? Have you tried selecting all 3 values manually? do you need to remove the “DEFAULT” value before you can select a 3rd value?

Maybe you’ll get lucky and someone else here has tested an app built with Oracle JET, and knows how to handle these fields, but I don;t think it’s a commonly used framework as I’d never heard of it before today.

Hope this is some help,

Dave.

Hi Dave,
Yes, Manually it was working fine.We can select as many values as we want

By default it is clicking In the center of the input box, so the first two times it works as the input box is blank, for the next time it fails as the text box is filled with text and when it clicks in the center of the box, it clicks on the text and the text gets heightened and no dropdown is seen.
How do I fix this? Any workaround

And since I am using this inbuild framework, how do I fix the issues I face while automating, if it’s not supported by selenium and robot.

Hi Madhurya,

What you have is a good start, what I meant by that. is keyword like Select From List By Value that are for dealing with standard HTML Option lists won’t work with these custom cobo-box lists.

You actually had something that was working well to start with and now you’ve identified why it’s not working on the third value, so perhaps Click Element At Coordinates is the solution you need? and I’d probably try combining it with Get Element Size

I’m guessing that this is the line that is clicking In the centre of the input box?:

click element //*[@class=‘oj-listbox-results’]

I’d probably try something like:

${field_x}    ${field_y}=    Get Element Size    //*[@class=‘oj-listbox-results’]
${field_offset}=    Evaluate    (${field_x}/2) - 5
Click Element At Coordinates    //*[@class=‘oj-listbox-results’]    ${field_offset}    0

This should click the middle of the input’s height and about 5 pixel in from the right side of the input.

If this then works well, and you have other similar cobo-boxes you need to test (//[@id=‘options-list’]?), you might want to adjust the xpath’s to ensure it only hits the input that relates to the //[@id=‘cipher-list’] field, maybe something like ${field_name}/..//[@class=‘oj-listbox-search-wrapper’]//input and then make the whole thing a keyword, something like “Select Ojet Cobo Box Values” that has 2 User keyword arguments, ${field_name} and ${names}, then you can do something like

${names}=    Create List    TLS_CHACHA20_POLY1305_SHA256    TLS_AES_128_CCM_SHA256    TLS_AES_256_GCM_SHA384
Select Ojet Cobo Box Values    //[@id=‘cipher-list’]    ${names}

Which will hopefully make your life easier for the next fields

Dave.

That’s Awesome Dave, It worked smoothly.

But How did you come up with this “${field_offset}= Evaluate (${field_x}/2) - 5”
How do I get the coordinates of the input box?
Does this “${field_offset}= Evaluate (${field_x}/2) - 5” work for other fields as well

Hi Madhurya,

Click Element At Coordinates, tells me it clicks at the centre of the element plus the offset and Get Element Size gives me the width which i saves as ${field_x} and height of the element, so 1/2 the width as an x offset from the centre, gives me the right hand edge which is why i used ${field_x}/2, I could also have done ${field_x} * 0.5 it’s the same thing, but I thought divide by 2 would be easier to understand. I then subtracted 5 from the result as I didn’t want to click on the edge of the field but inside it, the 5 is just an arbitrary number of pixels, i could have used 1,2,3,7 though 1 & 2 might be too close to the edge and become unreliable and 7 or anything more than 5 might result in intermittently encountering the original issue you had when you clicked the centre ( Click Element clicks the centre)

Yes it should as long as you do the other 2 lines first on the other elements, get the width, divide it by 2 and subtract 5 pixels and then use that calculated offset, if you don’t and instead just use the ${field_offset} calculated for the first field and the second field is much narrower you’ll end up clicking to the right of the second field and obviously that won’t give you the result you want.

Dave.

1 Like

Got it…!! Thank you so much Dave fo helping me out on this :slight_smile:

1 Like