Title: Tricky checkbox selection

David,

I would need to see the code to see what is happening. But if you are getting the collection of objects with the same name and then trying to sort that array you can’t. The reason is that the array of controls is really not an array it is unique object collection. If you want to send me some code I can take a look at it and see what I can come up with. The other thing that may help though I don’t know your circumstance is that you can use Xpath expressions against the DOM so you might be able to do something like that. See the previous post below that might be able to help you out.

 

Sergio

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

PREVIOUS POST:

 

Hi Paatsch,

 

How about using XPath to get the element in just one line of code rather then using the loops? In your case it would be something like

this:

 

ie.checkbox(:xpath, "//td[contains(., 'Test3')]/../td/input/").click()

 

This XPath query first select the <td> containing text Test3 (this is what you said is fixed and known before hand), then it goes to its parent i.e. <tr> and then traverse down the tree to first <td> and then <input> element inside that <td> which is the checkbox element that you want.

 

For using XPath download the tar ball from HEAD and read the documentation under the docs section.

 

Hope this helps.

 

Regards,

Angrez

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, January 24, 2006 8:52 AM
To: wtr-general@rubyforge.org
Subject: Re: [Wtr-general] Tricky checkbox selection

 

I ran into a similar problem and your suggestion worked great. However, I ran into slightly different problem. In my case, I have a list of users that can be updated and deleted. Every time I add a user, the value is increased by 1. For example,

 

<input  type="checkbox" name="selectedUsers" value="1"><user1>

<input  type="checkbox" name="selectedUsers" value="2"><user2>

 

and so on...

 

To find the last index value, I sorted the array to give the largest number. Knowing this I can delete the last user created. The problem is this: When I try to use any of the built in Array methods other than Sergio example, I get the following error:

 

WIN32OLERuntimeError: Unknown property or method `sort'
    HRESULT error code:0x80020006
      Unknown name.
    C:/Tests/TestSuites/tc_smoketest_suite.rb:93:in `method_missing'
    C:/Tests/TestSuites/tc_smoketest_suite.rb:93:in `test_delete_user
    C:/Tests/TestSuites/tc_smoketest_suite.rb:92:in `each'
    C:/Tests/TestSuites/tc_smoketest_suite.rb:92:in `test_delete_user

What am I doing wrong?

 

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to