Hybrid View
-
8 Nov 2012 4:21 AM #1
Unanswered: Set ID for SpinnerField up/down buttons
Unanswered: Set ID for SpinnerField up/down buttons
Hi,
To enable automation, I need to set IDs for SpinnerField up/down buttons.
Thanks in adv.
-
14 Nov 2012 1:42 PM #2
I've just spent about 20 minutes digging through the code and there does not appear to be a way to do this. The reason is that they are not actually buttons, even under the hood.
-
14 Nov 2012 5:13 PM #3
If you want predictable IDs on each up/down button, that'll be two things to set on each and every spinner field in your project. Reuse of any IDs will mean that you might click the wrong one, or that parts of the spinner field will no longer function correctly.
The quickest way I see that will make sense is to subclass SpinnerFieldDefaultAppearance, and add a pair of setters of IDs to use. Then, override the render method. You'll probably want to copy the existing implementation from TwinTriggerFieldDefaultAppearance.render. These two lines are responsible for building out the triggers themselves:
Code:sb.appendHtmlConstant("<div class='" + style.trigger() + "'></div>"); sb.appendHtmlConstant("<div class='" + style.twinTrigger() + "'></div>");
That said, be very wary about adding IDs throughout your app - it can make it hard to maintain, and ensure that you always have unique, but predictable IDs. Since you are already depending on a consistent approach to rendering the item, you can assume that the last two divs in the td in the spinner field will be the correct items - might look like #spinerId//td/div[1] and [2].
-
15 Nov 2012 8:59 AM #4
Ok, since my first post added zero value and Colin's did I feel compelled to say that using CSS class names is probably better than using IDs.
This is what we're doing for out automated tests in Selenium because the XPath is quite nasty otherwise and completely unreliable - first, I believe XPath values are different across browser vendors (and probably even versions) and second they are incredibly fragile as they are susceptible to changes in the DOM structure. I.e., if any widget (compound or otherwise, e.g., nested layouts) changes, the paths change.
-
15 Nov 2012 10:22 AM #5
icfantv - can you comment on how you access internal items like the up/down triggers by classname? Same issue will apply to DateField (and, I'm sure, DatePicker), ComboBox, etc.
-
17 Nov 2012 1:24 PM #6
From a Selenium perspective, I cannot as I do not write those automated tests. I can follow up with our System Test team and find out.
From a development perspective, I can - I just need to know which is preferred here.


Reply With Quote