Page 2 of 2

Re: Dropdown selection in IE 11 doesnot work

Posted: Fri Mar 17, 2017 10:50 am
by lila
I had a discussion with our developers here and it seems that they are passing empty string in first value of the list item. I am receiving the value as null for the first element and hence it is throwing a null pointer exception for me. I need to find a solution for it now. Thank you all for your valuable inputs

Re: Dropdown selection in IE 11 doesnot work

Posted: Fri Mar 17, 2017 12:48 pm
by odklizec
Hi,

I'm somewhat lost ;) When exactly it fail? Only if you pass the element "locationone"? Is there an element with such "Text" attribute in the list? If there is no such element, then of course, it must fail (not only in IE11, but IE9 too). If you want to select first (empty) item in the list, then you must most probably pass empty string to your method?

Re: Dropdown selection in IE 11 doesnot work

Posted: Wed Mar 22, 2017 2:10 pm
by lila
Hi,

Let me explain in detail about this issue. My script fails whenever a dropdown contains a null value as the first option. Example of the dropdown is mentioned below;
Dropdown.png
Here if you have noted the first listitem in the dropdown is null.

I am building my xpath as mentioned below;

ListItem item = "/container[@caption='selectbox']/listitem[@text='" + comboItem + "']";

So during the loop execution when a null value is assigned to the ListItem, it cannot handle null values and hence error occurs in that line and it comes out of loop and ends up selecting none of the dropdown. Also as mentioned before, our developers who built this website have purposefully made sure that TagValue for the null value dropdown is also null. Hence this error is triggered. Hope now I have explained clearly.

Re: Dropdown selection in IE 11 doesnot work

Posted: Wed Mar 22, 2017 4:18 pm
by Vaughan.Douglas
You might want to take a look at the select method on the Option object.

Since the option objects don't exist until the select box is clicked, you'll need to click on it. Once it's open then use your same RxPath, but rather than listitem use option.

"//option[@text='" + comboItem + "']";

I don't want to go through all of the permutations available for getting an object, but you're going to get that object and perform a .Select on it directly.

I've used this many many many many times on a particular Oracle application that does the same thing with its select boxes. In some instances the select box object isn't even the parent (or ancestor) of the option objects themselves. In those cases I just look for my option tag as a descendant of the base DOM. This can take Ranorex a little longer to find it, so you may need to try a couple of different approaches.

Let me know if you run into troubles implementing a solution.