[wtr-general] Re: click on html element

2010-08-18 Thread TCBlues
So it is not possible to access using something like
brow.element(:id,"xxx") or brow.object(:id,"xxx") or something
similar.
The only way is to know before hand what kind of tag we'll be
accessing.

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


[wtr-general] Re: click on html element

2010-08-18 Thread Chuck van der Linden
With the exception of using ID as the identifier, You can't do a
generic element, you need to invoke a method that is specific to the
element type, but if you know what kind of tag, then you know what
type of element (since tags define the elements)

You can access most elements by multiple means   Excepting the case of
attaching to a new browser window, ID, Name, Index, are nearly
universal, class works for everything but frames,  and 'text' works
for a majority of elements, and looks for the element according to the
text within it.

Using the contained text is often a great way to select a specific
div, link, cell, or even a row (sometimes via a reg-ex match on some
unique bit of text that will be found on that row).

'Clickable' text is almost always contained in some kind of other
element, it's really rare to see it 'naked' at the body level, just
purely due to the needs of isolating the 'clickability' to that text
only, instead of the entire body.  So generally if you know the
element, you can use .click on it.  If that doesn't work, have a
closer look at the HTML and try to find what javascript event is being
watched for, and fire that event at the element

Now, (unless it was changed recently) there is a bit of a loophole
with respect to identifying things by ID.  (and I'd recommend some
experimentation to validate this works for you, it's not a tactic I
use).  Since ID's are supposed to be unique within the document, it
appears that if you identify an element by ID, watir doesn't 'care'
about matching the element type, it just looks for the first
occurrence of that one specific ID, and returns whatever it finds. It
doesn't look to see if there's more than one (there never should be as
it's supposed to be unique) nor does it work well to use ID combined
with some other attribute (which in theory, you should never need to
do).  I've run into this by accident, where I specified the id wrong,
and despite asking for element type x, it returned element y which a
matching ID.

I don't know if that's intentional, or just a byproduct of the
assumption that the html will be valid, ID's will be unique, etc.
I've always considered it an 'undocumented feature' and hesitated to
use it in any of my scripts.

Sample html would help, or at the very least, what kind of tag

On Aug 18, 4:23 am, TCBlues  wrote:
> So it is not possible to access using something like
> brow.element(:id,"xxx") or brow.object(:id,"xxx") or something
> similar.
> The only way is to know before hand what kind of tag we'll be
> accessing.

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


[wtr-general] Re: unable to find element using xpath

2010-08-18 Thread Chuck van der Linden
On Aug 17, 8:23 am, goutham mandadi  wrote:
> Hai Chuck,
>
> Thanks for ur reply we can add id or name for this element but why is
> element by xpath is not working for me can u help me on this
>



Hai

b'cuz ur watir is wrong ur xpath failz

but i can has ask u why u want to?

becuz ur confuzin xpath is giant fail for

'I can plz has readable tests'

K Thx Bai

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


[wtr-general] Re: undefined method `element_by_xpath' for # (NoMethodError)

2010-08-18 Thread Chuck van der Linden
how in the world would I know what URL you need to use?  it's your app
not mine.  And you've never shared the URL with us.  I'm good, but I'm
not a mindreader

You can attach using either the URL of the page the window is
currently displaying or the Title of the page  For URL look at the
'address' area of your browser.  For title you can look at the
titlebar of the browser window, looking at the source HTML, or  via
using something like firebug or the IE developer Toolbar.

Note with title, omit anything like " - Internet explorer provided
by..."  which you might see when looking at the titlebar, just match
on the part before that.

On Aug 17, 8:35 am, goutham mandadi  wrote:
> Hi  Chuck,
>
> yeah you are right when logging in to application it is displayed as https
> and then at home page it is normal http. is their any specific url i need to
> give in how can u please give me an example
>
> Thanks,
> Goutham
>
> On Tue, Aug 17, 2010 at 8:39 PM, Chuck van der Linden wrote:
>
>
>
> > The most likely explanation when you see 'undefined method' (and you
> > haven't mispelled the method or something like that)  is that the
> > browser object is no longer pointing at an instance of a web browser.
>
> > That can happen in IE when the security context of the site changes
> > (e.g. the browser starts up in 'internet' but you are working with a
> > 'trusted site'.   it's almost like IE starts a fresh browser instance
> > and discards the old one, on the fly.
>
> > Try using something like
>
> > browser = Watir::IE.attach(:how, what)    (how usually being either
> > title or url)  to ensure you are pointing at an instance a browser
> > session, immediately before the step that is failing.
>
> > On Aug 16, 10:07 pm, goutham mandadi 
> > wrote:
> >  > Hai,
>
> > > can any one please help me on how to resolve this
>
> > > Thanks,
> > > Mandadi
>
> > --
> > Before posting, please readhttp://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 > legroups.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


[wtr-general] Regression in watir

2010-08-18 Thread nix
Iam new to watir and would like to maintain regression tests. If
one can suggest me to create a batch file or any tool that cn be
referred? Thanks Nix

-- 
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] Re: undefined method `element_by_xpath' for # (NoMethodError)

2010-08-18 Thread Ethan
Mandadi,
You need to share the code you are using, and if html is required to
demonstrate an error, preferably a minimal snippet of html (do not paste
several thousand lines of html into your email as some people have done).
see the guidelines: http://wiki.openqa.org/display/WTR/Support

On Wed, Aug 18, 2010 at 11:19, Chuck van der Linden wrote:

> how in the world would I know what URL you need to use?  it's your app
> not mine.  And you've never shared the URL with us.  I'm good, but I'm
> not a mindreader
>
> You can attach using either the URL of the page the window is
> currently displaying or the Title of the page  For URL look at the
> 'address' area of your browser.  For title you can look at the
> titlebar of the browser window, looking at the source HTML, or  via
> using something like firebug or the IE developer Toolbar.
>
> Note with title, omit anything like " - Internet explorer provided
> by..."  which you might see when looking at the titlebar, just match
> on the part before that.
>
> On Aug 17, 8:35 am, goutham mandadi  wrote:
> > Hi  Chuck,
> >
> > yeah you are right when logging in to application it is displayed as
> https
> > and then at home page it is normal http. is their any specific url i need
> to
> > give in how can u please give me an example
> >
> > Thanks,
> > Goutham
> >
> > On Tue, Aug 17, 2010 at 8:39 PM, Chuck van der Linden  >wrote:
> >
> >
> >
> > > The most likely explanation when you see 'undefined method' (and you
> > > haven't mispelled the method or something like that)  is that the
> > > browser object is no longer pointing at an instance of a web browser.
> >
> > > That can happen in IE when the security context of the site changes
> > > (e.g. the browser starts up in 'internet' but you are working with a
> > > 'trusted site'.   it's almost like IE starts a fresh browser instance
> > > and discards the old one, on the fly.
> >
> > > Try using something like
> >
> > > browser = Watir::IE.attach(:how, what)(how usually being either
> > > title or url)  to ensure you are pointing at an instance a browser
> > > session, immediately before the step that is failing.
> >
> > > On Aug 16, 10:07 pm, goutham mandadi 
> > > wrote:
> > >  > Hai,
> >
> > > > can any one please help me on how to resolve this
> >
> > > > Thanks,
> > > > Mandadi
> >
> > > --
> > > Before posting, please readhttp://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
> 
>
> --
> 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
>

-- 
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] Re: Does anybody have experience to run ruby watir script in a cgi script?

2010-08-18 Thread chengfeng han
Hi, Bill,

I found the problem, I first put runner on
G:\Documents and Settings\Administrator\My Documents\runner
I saw some errors "ruby G:\Documents and .,  Could not access
G:\Documnets and ..."
"Wed Aug 18 12:19:54 -0400 2010: Read error: #"

Then I put runner on G:\runner
It works fine now.

Thanks!

Jennifer

On Mon, Aug 16, 2010 at 9:50 PM, Bill Agee  wrote:

> Hi,
>
> After you launched your script via the runner app, did it seem to execute
> successfully?  (I'm assuming you used the google test suite that's displayed
> on the main page of the app after it's started...)  Or did the script you
> attempted to launch not run?
>
> The behavior you saw is normal if a test suite takes a long time to
> complete - the viewconsole page (the one with the header "Console output:")
> will refresh itself every 2 seconds while a test is running.
>
> But if a test suite finishes and the viewconsole page keeps refreshing,
> it's probably because the script being launched does not use Test::Unit.
>
> The viewconsole page waits for one of the result lines seen in Test::Unit's
> output to appear in the output...but if that line is never seen then the
> refresh will recur until the browser is closed.
>
> I wrote that part a really long time ago when depending on Test::Unit
> seemed like a reasonable idea. :)  In hindsight the app should simply stop
> refreshing the viewconsole page as soon as the script completes.
>
> Thanks
> Bill
>
>
> On Mon, Aug 16, 2010 at 2:48 PM, WatirJoy  wrote:
>
>> Hi, Charles and other Watir experts,
>>
>> When I tried to execute a few line of ruby watir scripts in a cgi
>> script, the page keep waiting, then timeout. Anyway, you mentioned
>> rails app wiki:http://wiki.openqa.org/display/WTR/Rails+test+runner
>> +example+app
>> is what I am looking for. I followed the steps mentioned in the web
>> page:
>>
>> 1)On the client that will run the tests, install rails with 'gem
>> install rails'
>> 2)Download runner.zip from the link below, and extract it in any dir
>> on the client.
>> 3)Start a cmd.exe shell and cd into the extracted 'runner' dir.
>> 4)Launch the app with the command "ruby script/server"
>> 5)From either the local or a remote machine, open a browser and access
>> http://HOST:3000 
>> (where HOST is your machine's address)
>> 6)Attempt to run the google test suite. (Note: Watir must be installed
>> for the google suite to work.)
>>
>> But no console output, web server looked like keep looping:
>>
>> Processing RunnerController#viewconsole (for 127.0.0.1 at 2010-08-16
>> 17:39:56)
>> POST]
>>  Parameters: {"authenticity_token"=>"D9j5PjYTwpBxKU4CyVQH/
>> cHn14FVGl8Vak9BIjs8j
>> g="}
>> Rendering runner/viewconsole
>> Completed in 0ms (View: 0 | 200 OK [http://localhost/runner/
>> viewconsole]
>> sole]
>>
>>
>> Processing RunnerController#viewconsole (for 127.0.0.1 at 2010-08-16
>> 17:39:58)
>> POST]
>>  Parameters: {"authenticity_token"=>"D9j5PjYTwpBxKU4CyVQH/
>> cHn14FVGl8Vak9BIjs8j
>> g="}
>> Rendering runner/viewconsole
>> Completed in 0ms (View: 0 | 200 OK [http://localhost/runner/
>> viewconsole]
>> sole]
>>
>>
>> Processing RunnerController#viewconsole (for 127.0.0.1 at 2010-08-16
>> 17:40:00)
>> POST]
>>  Parameters: {"authenticity_token"=>"D9j5PjYTwpBxKU4CyVQH/
>> cHn14FVGl8Vak9BIjs8j
>> g="}
>> Rendering runner/viewconsole
>> Completed in 0ms (View: 0 | 200 OK [http://localhost/runner/
>> viewconsole]
>> sole]
>>
>>
>> Processing RunnerController#viewconsole (for 127.0.0.1 at 2010-08-16
>> 17:40:02)
>> POST]
>>  Parameters: {"authenticity_token"=>"D9j5PjYTwpBxKU4CyVQH/
>> cHn14FVGl8Vak9BIjs8j
>> g="}
>> Rendering runner/viewconsole
>> Completed in 0ms (View: 0 | 200 OK [http://localhost/runner/
>> viewconsole]
>> sole]
>>
>> Did I miss something?
>>
>> Thanks!
>>
>>
>>
>>
>>
>>
>>
>>
>> On Aug 13, 4:11 pm, Charley Baker  wrote:
>> > I don't have experience doing that with cgi. And you definitely want to
>> back
>> > up a few steps and give us more information. Honestly, I wouldn't do
>> that,
>> > there's a rails app that's a good start on the Watir wiki:
>> http://wiki.openqa.org/display/WTR/Rails+test+runner+example+app If you
>> > want continuous integration then there are multiple pages and refs out
>> there
>> > for that.
>> >
>> > Hopefully that app will give you a starting point, though I've not used
>> it,
>> > people can chime in. My only guess is you want to do something like
>> that?
>> > Again given your email it's hard to tell what you're looking for and
>> what if
>> > any errors you're experiencing.
>> >
>> > hth,
>> >
>> > Charley Baker
>> > Lead Developer, Watir,http://watir.com
>> >
>> >
>> >
>>  > On Fri, Aug 13, 2010 at 1:15 PM, WatirJoy 
>> wrote:
>> > > Hi,
>> >
>> > > I tried to execute a few line of ruby watir scripts in a cgi script:
>> >
>> > > #!/ruby/bin/ruby -w
>> > > require 'cgi'
>> > > require 'stringio'
>> > > require 'rubygems'
>> > > require 'mysql'
>> > > require 'watir'
>> > > require 'time'
>> > > cgi = CGI.new

Re: [wtr-general] Re: unable to find element using xpath

2010-08-18 Thread goutham mandadi
Hai charley,

I ahev installed from gems C:\ruby\lib\ruby\gems\1.8\gems in this path i am
having commonwatir-1.6.5 and firewatir-1.6.5 and watir-1.6.5 folders when i
run from this path i am getting th following error

one.rb:7: undefined method `click' for nil:NilClass (NoMethodError)
require 'watir'
ie = Watir::IE.start("http://www.snapfish.com/login";)
ie.text_field(:name, "emailaddress").set("goutham.mand...@valuelabs.net")
ie.text_field(:name, "password").set("sfqatest")
ie.button(:name, "log in").click
ie.element_by_xpath("//ar...@href='www5.snapfish.com/snapfish/youraccount'
]").click

waht might be the reason for this anyone help me

Thankyou,
Goutham

this is code i am using
On Tue, Aug 17, 2010 at 10:52 PM, Charley Baker wrote:

> Shouldn't be in site_ruby, that's gotta be version 1.4.1 with the Watir
> installer. Uninstall that and make sure you're reinstall the Watir gem,
> worst case wipe the ruby directory and install the latest Watir gem, should
> be 1.6.5 and run from the gem directory, not site_ruby.
>
>
> Charley Baker
> Lead Developer, Watir, http://watir.com
>
>
>
> On Tue, Aug 17, 2010 at 11:08 AM, goutham mandadi <
> goutham.mand...@gmail.com> wrote:
>
>> Hai,
>>
>> c:/ruby/lib/ruby/site_ruby/1.8/watir.rb this is path from which it is
>> executing here in watir.rb i couldnot find method element_by_xpath
>> how to add this
>>
>> thanks,
>> goutham
>>
>> On Tue, Aug 17, 2010 at 9:08 PM, goutham mandadi <
>> goutham.mand...@gmail.com> wrote:
>>
>>> Hi eric,
>>>
>>> I did not get you what are orb and .flash i am new to watir
>>>
>>> Thanks,
>>> Goutham
>>>
>>>   On Tue, Aug 17, 2010 at 8:58 PM, Eric Mathiesen >> > wrote:
>>>
 You could also use orb and .flash the index.

  On Aug 17, 2010 8:23 AM, "goutham mandadi" 
 wrote:

 Hai Chuck,


 Thanks for ur reply we can add id or name for this element but why is
 element by xpath is not working for me can u help me on this

 Thankyou,
 Goutham

 On Tue, Aug 17, 2010 at 8:48 PM, Chuck van der Linden 
 wrote: > > As an alternativ...

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


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

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


[wtr-general] Re: Regression in watir

2010-08-18 Thread orde
If you haven't already, I'd start with the tutorial to get familiar
with watir: http://wiki.openqa.org/display/WTR/Tutorial

There's a section called Running Tests that discusses a couple of
commonly-used test frameworks: rspec and Test::Unit.

Hope it helps.

orde

On Aug 18, 8:31 am, nix  wrote:
> Iam new to watir and would like to maintain regression tests. If
> one can suggest me to create a batch file or any tool that cn be
> referred? Thanks Nix

-- 
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] Re: unable to find element using xpath

2010-08-18 Thread Ethan
I don't think that you should be using element_by_xpath at all. It does not
return a Watir::Element. You should use a normal element accessor with the
:xpath specifier:
ie.area(:xpath, "//whatever/").click


On Wed, Aug 18, 2010 at 13:18, goutham mandadi wrote:

>
> Hai charley,
>
> I ahev installed from gems C:\ruby\lib\ruby\gems\1.8\gems in this path i am
> having commonwatir-1.6.5 and firewatir-1.6.5 and watir-1.6.5 folders when i
> run from this path i am getting th following error
>
> one.rb:7: undefined method `click' for nil:NilClass (NoMethodError)
> require 'watir'
> ie = Watir::IE.start("http://www.snapfish.com/login";)
> ie.text_field(:name, "emailaddress").set("goutham.mand...@valuelabs.net")
> ie.text_field(:name, "password").set("sfqatest")
> ie.button(:name, "log in").click
> ie.element_by_xpath("//ar...@href='www5.snapfish.com/snapfish/youraccount'
> ]").click
>
> waht might be the reason for this anyone help me
>
> Thankyou,
> Goutham
>
> this is code i am using
> On Tue, Aug 17, 2010 at 10:52 PM, Charley Baker 
> wrote:
>
>> Shouldn't be in site_ruby, that's gotta be version 1.4.1 with the Watir
>> installer. Uninstall that and make sure you're reinstall the Watir gem,
>> worst case wipe the ruby directory and install the latest Watir gem, should
>> be 1.6.5 and run from the gem directory, not site_ruby.
>>
>>
>> Charley Baker
>> Lead Developer, Watir, http://watir.com
>>
>>
>>
>> On Tue, Aug 17, 2010 at 11:08 AM, goutham mandadi <
>> goutham.mand...@gmail.com> wrote:
>>
>>> Hai,
>>>
>>> c:/ruby/lib/ruby/site_ruby/1.8/watir.rb this is path from which it is
>>> executing here in watir.rb i couldnot find method element_by_xpath
>>> how to add this
>>>
>>> thanks,
>>> goutham
>>>
>>> On Tue, Aug 17, 2010 at 9:08 PM, goutham mandadi <
>>> goutham.mand...@gmail.com> wrote:
>>>
 Hi eric,

 I did not get you what are orb and .flash i am new to watir

 Thanks,
 Goutham

   On Tue, Aug 17, 2010 at 8:58 PM, Eric Mathiesen <
 mathiese...@gmail.com> wrote:

> You could also use orb and .flash the index.
>
>  On Aug 17, 2010 8:23 AM, "goutham mandadi" 
> wrote:
>
> Hai Chuck,
>
>
> Thanks for ur reply we can add id or name for this element but why is
> element by xpath is not working for me can u help me on this
>
> Thankyou,
> Goutham
>
> On Tue, Aug 17, 2010 at 8:48 PM, Chuck van der Linden <
> sqa...@gmail.com> wrote: > > As an alternativ...
>
>  --
>  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
>
>

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

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


[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:
  ...

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"  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:
 ...

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

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


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

2010-08-18 Thread jasbro
After I posted this question, I started thinking that the best
solution would be if I could use a regular expression to select the
element:
  @browser.div(:id,/^amount_.*/)
or
  @browser.div(:class,/.*amount.*/)

So I tried it, and it worked for both Firefox and IE.  This may just
be a benefit of using Ruby, or it may have been intentional (I don't
know...I'm a Java guy) but I'm really glad it worked.  Hope anyone
else who comes across this question finds this useful.


On Aug 18, 2:40 pm, jasbro  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:
>   ...
>
> 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