I have not used Ranorex in a few years, so bear with me, please. I know this is basic. I have a <select> in my repository. I want to write some user code or test module steps (don't care) to select one of the options that becomes visible when the <select> is clicked by text. All the examples I am finding are not using an existing repository item... so I am not learning from the examples I see. This is pretty basic. Thanks!
S
select option in <select? box on web page ... noob
Re: select option in <select? box on web page ... noob
Hi,
Item selection in "select" box heavily depends on the implementation of select box in question. Could you please provide a snapshot of the select box or even better, a working HTML sample (e.g. using this page https://www.w3schools.com/tags/tryit.as ... tml_select)?
Item selection in "select" box heavily depends on the implementation of select box in question. Could you please provide a snapshot of the select box or even better, a working HTML sample (e.g. using this page https://www.w3schools.com/tags/tryit.as ... tml_select)?
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: select option in <select? box on web page ... noob
Spanshot I will try a working sample now.
- Attachments
-
- widgetselect.rxsnp
- (55.63 KiB) Downloaded 35 times
Re: select option in <select? box on web page ... noob
Hi,
OK, in my opinion, the easiest approach is to click the select box (to expanded it) and then click the option you want to select. For this, you need to create two repository elements. First pointing to select box, the second one to the option you want to click. And because you most probably don't want to create a repo item for each option in the select list, you should variabilize it.
So the xpath for select element should be like this:
OK, in my opinion, the easiest approach is to click the select box (to expanded it) and then click the option you want to select. For this, you need to create two repository elements. First pointing to select box, the second one to the option you want to click. And because you most probably don't want to create a repo item for each option in the select list, you should variabilize it.
So the xpath for select element should be like this:
and the xpath for select option like this://div[#'SMBHOME']//form[@name='widget-injector-form']/select[@name='widget-injector']
Then drag&drop first repo element (select item) to the recording of your choice and from the appeared menu select Mouse click action. Then D&D second element and make sure the variable is filled with select option you want to select (via data connector or test case/smart folder parameter). Now of you run your test, it should expand the select element and then pick the option you specified in variable. Hope this helps?//div[#'SMBHOME']//form[@name='widget-injector-form']/select[@name='widget-injector']/option[@innertext=$optionString]
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: select option in <select? box on web page ... noob
Ok, by way of research I tried something like this-ish. I did a recording of clicking the select, then the option. The option was added to the repo. When I played it back, the test ran successfully, but no click occurred on the application.
Thanks
Thanks
Re: select option in <select? box on web page ... noob
Hi,
Unfortunately, it's too hard/impossible to tell what's wrong without seeing, at very least, the problematic recording with included repository (and snapshot). What you can try is to enable "Turbo" mode for given recording, which may eliminate some click-related errors, caused by too slow mouse movement. This kind of problems usually happens in tests started on virtual machine (accessed via RD). But it's worth a try also in your case?
Unfortunately, it's too hard/impossible to tell what's wrong without seeing, at very least, the problematic recording with included repository (and snapshot). What you can try is to enable "Turbo" mode for given recording, which may eliminate some click-related errors, caused by too slow mouse movement. This kind of problems usually happens in tests started on virtual machine (accessed via RD). But it's worth a try also in your case?
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: select option in <select? box on web page ... noob
Alrighty, I got confused as I tried different things. When I did a recording, the step that was created was SetValue, not the 2 subsequent clicks like I thought. The select box is like
<select name="MyName">
<option value="-1">Add My Thing</option>
<option value="stupidrandomcode">Thing To Add</option>
....
When I recorded, the SetValue was setting the value to -1, thus my play back looked like it was not working. Ok, ok, this very well could have been operator (me) error. But when I SetValue to stupidrandomcode, the correct selection is made.
Solution! Thanks for your help!
<select name="MyName">
<option value="-1">Add My Thing</option>
<option value="stupidrandomcode">Thing To Add</option>
....
When I recorded, the SetValue was setting the value to -1, thus my play back looked like it was not working. Ok, ok, this very well could have been operator (me) error. But when I SetValue to stupidrandomcode, the correct selection is made.
Solution! Thanks for your help!
Re: select option in <select? box on web page ... noob
Hmmmm, is there any chance I have discovered a bug in the recorder code? I tried to record this again and definitely selected an option item. I got value = -1 as my value in the recorded step. No skin off my nose since I know what to do. But I wondered. Thanks.
Re: select option in <select? box on web page ... noob
Hi,
No, it’s not a bug. The thing is, that recorder prefers to use SetValue action for combo boxes. And the problem is, that in case of your Select box, there are different TagValues, which are not visible for user, and Text values, which are actually visible in select box. But because TagValue is prioritised for SetValue action, recorder picks -1, which is the TagValue for item you have selected during recording. I believe you selected the first item in the list? If you select different item, the recorded TagValue will be something else than -1.
To be honest, I would replace recorded SetValue action with mouse click actions. SetValue is not exactly user-based approach and may not trigger certain mouse-based events, eventually attached to the select box in question. Picking select box element with mouse is simply more appropriate way of selecting items in combo boxes.
No, it’s not a bug. The thing is, that recorder prefers to use SetValue action for combo boxes. And the problem is, that in case of your Select box, there are different TagValues, which are not visible for user, and Text values, which are actually visible in select box. But because TagValue is prioritised for SetValue action, recorder picks -1, which is the TagValue for item you have selected during recording. I believe you selected the first item in the list? If you select different item, the recorded TagValue will be something else than -1.
To be honest, I would replace recorded SetValue action with mouse click actions. SetValue is not exactly user-based approach and may not trigger certain mouse-based events, eventually attached to the select box in question. Picking select box element with mouse is simply more appropriate way of selecting items in combo boxes.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: select option in <select? box on web page ... noob
In answer to this:
I believe you selected the first item in the list? If you select different item, the recorded TagValue will be something else than -1.
The answer is no, I selected a different item.
But I will try your click method instead. Thanks.
I believe you selected the first item in the list? If you select different item, the recorded TagValue will be something else than -1.
The answer is no, I selected a different item.
But I will try your click method instead. Thanks.