Results 1 to 6 of 6

Thread: Set ID for SpinnerField up/down buttons

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default Set ID for SpinnerField up/down buttons

    Hi,

    To enable automation, I need to set IDs for SpinnerField up/down buttons.

    Thanks in adv.

  2. #2
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    413
    Answers
    20
    Vote Rating
    21
      0  

    Default

    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.

  3. #3
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Answers
    109
    Vote Rating
    93
      0  

    Default

    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].

  4. #4
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    413
    Answers
    20
    Vote Rating
    21
      0  

    Default

    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.

  5. #5
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Answers
    109
    Vote Rating
    93
      0  

    Default

    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.

  6. #6
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    413
    Answers
    20
    Vote Rating
    21
      0  

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •