Radio button click in Selenium Webdriver - asp.net

I have write a code for radio button click by using XPath but it is not click on radio button during execution of code.
My code is:
driver.FindElement(By.XPath("//a[contains(id(),rptShoppingServiceGroup_dlAddons_2_ctl01_2)]")).Click();
Kindly help how to button select particular radio button and after selection it move to another radio button.
Thanks in advance.

Actually the click() works, but the webdriver can't properly refresh the user interface...
The unique methode i've found to refresh that is to use the submit() function on it.
Like :
myRadioBtn.click();
myRadioBtn.submit();
tell me what's up =)

It might be case that you're checking radio button which is already checked. Hence now, you have radio button unchecked which you don't want(you want radio button to be checked). First check whether radio button is checked. If it's checked, don't click on it(otherwise, it'll result into uncheck of radio button). If it's not checked, then click on it so it will be checked.
button = driver.FindElement(By.XPath("//a[contains(id(),rptShoppingServiceGroup_dlAddons_2_ctl01_2)]"))
if (!button.isSelected()){
button.click();
assetTrue(button.isSelected)
}

Do you want RadioButton checked?
if yes, try ...Checked=true
var radioButton = driver.FindElement(By.XPath("//a[contains(id(),rptShoppingServiceGroup_dlAddons_2_ctl01_2)]"));
radioButton.Checked=true;
(or radioButton.Click())

Related

How to peoplecode with radio button

Anyone of you who knows how to peoplecode with the value choosen with radio button?
I have this page with radio button of academic programs and when a user select from one of the programs, I want to print a report basing on that program chosen in the radio button.
Any idea where to start and how to do this?
Thanks so much for the help.
Open the page in Application Designer and check the properties of the radio button fields.
They will look something like this:
All the related radio buttons will have the same record and field, but a different value.
To execute code, based on the selected radio button, you would evaluate the value:
Evaluate RECORD.FIELD.Value
When "VAL1"
RunReport1();
When "VAL2"
RunReport2();
When-Other
/* Error */
End-Evaluate;
Note: Fields used for radio buttons have to have XLAT validation IIRC

How to set the old value which was selected earlier, after a value change event fired

I am facing a problem like I have one Vaadin ComboBox with preselected value.I am changing the value from the ComboBox to another value,then ValueChangeEvent is fired.Inside the valueChange method I have written something to show a Popup Window which has Cancel and Ok button.Upon clicking on OK button of Popup Window I am going with the changed value of the ComboBox but upon clicking on Cancel button I just want to have the old value which was there before value change event fired.
Could anyone please help me out from the above issue?
Thanks in advance.
Maybe you can save whatever SelectedItem the combobox has when the event is fired, and if the user pressed cancel, you reset it to this stored item.
Before the click, how do you know what is selected in the click? Of course, you need to store the current selection somewhere. Lets call it currentSelectedValue (it could be NULL in the begining)
On click, you have a new selection, lets call it newSelectedValue
Now, if you do not want to go with this newSelectedValue, simply do this:
combo.setValue(currentSelectedValue);

Radio Button won't stay check if I have a modal window open up when it is selected

In a asp.net web project when the user selects a radio button I need a modal window to open up and prompt for user credentials.
I have the "TargetControlID" set to the radio button. The modal opens up just fine but when it goes away the radio button isn't checked.
EDIT:
Removed code for personal reasons
When the Modal goes away, just recheck the radio button
$("radio button").attr('checked',true);

jQuery UI: Button opens Dialog / Button doesn't change status

if I use a button to open a dialog, the button doesn't change the status to normal (stay on ui-state-hover).
How can I tell the button to change back after clicking on it?
Hope some1 can help me :)
I believe ui-state-focus is the class that's being added when the button is clicked. If you add this to the end of the buttons 'click' event, it should reset it to a normal state.
$('#button').toggleClass('ui-state-focus');

Are there any keyboard shortcuts for RadioButton and Checkbox?

I have a lot of data-entryists using my ASP.NET application and we have all been wondering if there are any keyboard keys or shortcuts that you can press to trigger:
Check a RadioButton
Uncheck a RadioButton
Check a Checkbox
Uncheck a Checkbox
I know that you can write Javascript and do it yourself, but do any keyboard keys/shortcuts already exist without using the mouse?
Spacebar is the standard button for those, with arrow keys to move between radio buttons.

Resources