Is there a way in Selenium RC to get the id from the xpath?
If I have the xpath
/html/body/div/div//input
I want to get the id of all the nodes associated to the xpath
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can get that by running a javascript, using
this.browserbot.findElement('/html/body/div/div//input'):Of course, this depends on the source language, but it would be something like this (in perl, untested):
I always thought there should be a more direct way to do this, but I haven’t found it yet!
EDITED based on the comments, the for loop count should start from 1 and include
$count, also the findElement line only needs one forward-slash before input.EDIT2 Adding a completely different idea based on further comments:
Selenium’s javascripts that get attached to every page include a function called
eval_xpaththat returns an array of DOM elements for a given query. Sounds like what you want?Here’s what I think the javascript would look like (again, untested):