views:

32

answers:

2

I have the following input element:

<input name='selected(1234)' type="checkbox" />

When I record, I get this:

Command: click
Target: selected(1234)

This doesn't find the element, and neither does

Target: name=selected(1234)

My assumption is that the parentheses are somehow messing with the lookup. What's the proper way to do this?

A: 

Try using an XPath:

Command: click
Target: xpath=//input[@type='checkbox'][@name='selected(1234)']

However, if you're trying to check (as in mark not verify) the checkbox, you really should use:

Command: check
Target: xpath=//input[@type='checkbox'][@name='selected(1234)']
Wesley Wiser
Any reason for the downvote?
Wesley Wiser
It doesn't work. What else would I downvote for?
Stefan Kendall
Is there an error message from selenium or javascript error?
Wesley Wiser
Wait a second, why are you trying to click on the checkbox? Are you simply trying to check it or are you trying to trigger the onclick event?
Wesley Wiser
...this is a selenium-RC test. Of course I'm actually trying to click it.
Stefan Kendall
I mean, are you trying to check\uncheck the checkbox?
Wesley Wiser
Using Selenium RC and Python this works and so does name=selected(1234). Are you working in the right frame? Can you tell us the exact error that you are getting.
AutomatedTester
Element not found, and there are no frames on the page.
Stefan Kendall
I think you may be right about the parenthesis messing with the lookup. What about a locator that doesn't include parenthesis in the name like: `xpath=//input[@type='checkbox'][contains(@name, 'selected')][contains(@name, '1234')]`?
Wesley Wiser
A: 

This could be a timing issue. If you record a test in selenium-IDE, it won't give you the waitForPageLoad commands you need when you convert the test to java.

Stefan Kendall