Is it possible to select the ids of radio buttons in a page using selenium..?
Is there any method that will does this function..?
Anyone knowing please help...
click | //input[contains(@id,'_id3:0')]
Thank you for the reply.
Is there any method to get the ids of all radio buttons on an html page?
I got only method that returns the ids of all Buttons. But couldn't find any method to get ids of radio buttons.
No, there is no such function, but you may easy create such, based on the getAllButtons implementation:
BrowserBot.prototype.getAllButtons = function() {
var elements = this.getDocument().getElementsByTagName('input');
var result = '';
for (var i = 0; i < elements.length; i++) {
if (elements.type == 'button' || elements.type == 'submit' || elements+.type == 'reset') {
result = elements.id;
result += ',';
}
}
return result;
};
To get the radio buttons, you need to check for type='radio' instead.
I am using Selenium Remote control script using java for automation.
Can you please tell how to use the javascript snippet above in my Selenium RC script?
Sure.
This function is an already available one - it is used when you call the method returning all the button ids. So you need to extend Selenium (read about extending the code here:
http://www.openqa.org/selenium-core/reference.html]
with an additional function (getAllRadioButtons for example), which checks about "radio" type of the elements (as I posted above) and then call the respective method in your Java test case.
Message was edited by: konstantin.petkov
I installed selenium core and edited the file "selenium-core-0.8.2/core/scripts/user-extensions.js"
but still i am getting the error "cannot find symbol" on runnung the test file.
I am not sure if I need to install "selenium core" or is it enough to include the js file in selenium RC folder itself.
Can anyone please help with my issue...?
Unfortunately I don't know the answer and haven't seen the error you posted above so far. Why don't you post your question in Selenium RC forum, where more people working with the remote control will be able to see the problem?
http://forums.openqa.org/forum.jspa?forumID=13
Sorry for not being able to help you further.
Thank You so much for the kind help. ![]()
I've tried next code in the user-extensions.js : (using Selenium Core)
BrowserBot.prototype.getAllRadios = function() {
var elements = this.getDocument().getElementsByTagName('input');
var result = '';
for (var i = 0; i < elements.length; i++) {
if (elements+.type == 'radio') {
result = elements.id;
result += ',';
}
}
return result;
};
but using command:
storeAllRadios | rad1 |
returns error:
Unknown command: 'storeAllRadios'
why this happens?
I guess you need to define the command in selenium-api.js as well. Just call the one from browserbot there.
thx! it works fine
have changed selenium-api.js
have added function to the selenium-browserbot.js - do not know why user-extensions.js do not work for me
I would like to know whether you have edited the files "selenium-api.js" and "selenium-browserbot.js" under Selenium Core.
If you have included these files in Selenium RC please tell the location to create these files.
Please help.
