CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How radio buttons get their IDs assigned in CiviCRM
Pages: [1]

Author Topic: How radio buttons get their IDs assigned in CiviCRM  (Read 1541 times)

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
How radio buttons get their IDs assigned in CiviCRM
October 09, 2009, 12:37:17 am
I was experimenting a little with Selenium in order to speed up a test of a donation page, and found something really odd.

The page contains a custom profile with a number of Yes/No type questions.  When I recorded filling in the form in Selenium and replayed the page, the script died as soon as it got to the radio buttons.  The reason surprised me.

Using the Selenium "HTML" format for its tests, a click on one of the radio buttons looks like this:
Code: [Select]
<tr>
<td>click</td>
<td>qf_732258</td>
<td></td>
</tr>

That funny looking string, "qf_732258",  was the ID of the first radio button (a "Yes" answer).    Playback in Selenium failed because, well, every time you generate the page, the ID of the buttons changes to something completely random.

This makes it really hard to do anything not only in Selenium but also in JavaScript, since both systems want to know the DOM ID of the object you're manipulating.

Since the ID start with "qf_", I'm guessing this is QuickForm funniness.    Which likely means it would be hard to change this behavior.  But is there anything we can do so that the ID of these objects stays the same, so that it's even possible to use Selenium or jQuery on CiviCRM radio buttons?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: How radio buttons get their IDs assigned in CiviCRM
October 09, 2009, 07:47:10 am

this is a QF fix and Tom K recently filed an issue on this. We need to take a look at it and figure out how to generate a sane id from the name/value rather than a random number

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: How radio buttons get their IDs assigned in CiviCRM
October 09, 2009, 09:59:25 am
Yeah, I figured it was at this level.

It appears that in general, you can pass in the ID with the $attributes array.  How that would work with groups of radio buttons I don't know, although I'd guess you folks directly call addElement for each individual button, so it's at least possible.

Not a critical problem, obviously, but it did look a little wonky.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How radio buttons get their IDs assigned in CiviCRM

This forum was archived on 2017-11-26.