[wtr-general] Select an element when :id and :class are not completely known

2010-08-18 Thread jasbro
In the jQuery world, it isn't uncommon for me to dynamically add
classes to an element.  Depending on various circumstances, the class
of a div might be something like amount or amount required or
amount required invalid.  In my particular situation, the problem is
compounded by the fact that my id is partially made up of a random
number, so I can't simply do div(:id,amount).  What I do know is the
first chunk of the id (e.g. it always starts with amount_).  I also
know that the class will always contain amount, though it may also
contain additional classes.  An example:
  div id=amount_1239783 class=required amount invalid.../div

1. I've tried to do @ff.div(:class,amount) but it only works if they
other classes haven't been added
2. I know I can do @ff.div(:class,required amount invalid) but
sometimes the classes get added in a different order (and some classes
don't get added every time, so maintaining all the possible
combinations is ridiculous)
3. I know I can do each through the divs looking to see if the class
contains the given value, or the id starts with amount, but that seems
excessive

Does anyone know if there is a simple way to do this?

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe: watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Select an element when :id and :class are not completely known

2010-08-18 Thread Eric Mathiesen
When I run into this I use :index, #

On Aug 18, 2010 2:52 PM, jasbro jas...@gmail.com wrote:

In the jQuery world, it isn't uncommon for me to dynamically add
classes to an element.  Depending on various circumstances, the class
of a div might be something like amount or amount required or
amount required invalid.  In my particular situation, the problem is
compounded by the fact that my id is partially made up of a random
number, so I can't simply do div(:id,amount).  What I do know is the
first chunk of the id (e.g. it always starts with amount_).  I also
know that the class will always contain amount, though it may also
contain additional classes.  An example:
 div id=amount_1239783 class=required amount invalid.../div

1. I've tried to do @ff.div(:class,amount) but it only works if they
other classes haven't been added
2. I know I can do @ff.div(:class,required amount invalid) but
sometimes the classes get added in a different order (and some classes
don't get added every time, so maintaining all the possible
combinations is ridiculous)
3. I know I can do each through the divs looking to see if the class
contains the given value, or the id starts with amount, but that seems
excessive

Does anyone know if there is a simple way to do this?

--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.

You received this message because you are subscribed to
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe:
watir-general+unsubscr...@googlegroups.comwatir-general%2bunsubscr...@googlegroups.com

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe: watir-general+unsubscr...@googlegroups.com