Find element by label

289 views
Skip to first unread message

Aslak Hellesøy

unread,
Nov 17, 2009, 12:46:50 AM11/17/09
to webdriver
Consider:

<label for="uglyname">Nice Name</label>
<input id="uglyname" />

I would *like* to just say:

browser.findElement(By.label("Nice Name"))

And have that return the input element. Webrat does this and I love
it. Any way to do this in WebDriver?

Aslak

Marc Guillemot

unread,
Nov 17, 2009, 2:27:08 AM11/17/09
to webd...@googlegroups.com
What about implementing it by yourself, using an XPath in the background?

id(//label[text() = 'your label here']/@for)

Cheers,
Marc.

Aslak Hellesøy a écrit :

Simon Stewart

unread,
Nov 19, 2009, 7:20:52 AM11/19/09
to webd...@googlegroups.com
You're not the first person to request something like this. I like the
way that chickenfoot deals with this problem. Emulating that behaviour
would be nice.

Simon

QA_manager

unread,
Nov 19, 2009, 9:14:06 AM11/19/09
to webdriver
I assume that you mean this chickenfoot: http://groups.csail.mit.edu/uid/chickenfoot/
- the Firefox extension, not the American rock group by the same
name. What does it do that you like so much?

Simon Stewart

unread,
Nov 19, 2009, 10:05:33 AM11/19/09
to webd...@googlegroups.com
The element finding is nice, in that it tries to make things really
easy for the user. In the simple case, this makes for simpler tests.

Simon
Reply all
Reply to author
Forward
0 new messages