How to select specific radio button in a group of similar radio buttons in Selenium Web Driver? - xpath

I am trying to automate a booking process from an airline site.
In the second page of the booking process ('Select Flights'), there are multiple radio buttons which are very similar with other radio buttons available in the page. How can I select the radio button that I want to click?
I have already tried the xpath of the radio button but to no avail.
Here is the html code of the radio button:
Screenshot from booking.airasia.com
Please advise. Thank you

First element
Second Element
Well its true that you are getting similar elements for that given xpath but you also have to go through their siblings/parents etc for different scenarios.
Here is the xpath I tried that identified the individual elements that you were looking for, are depicted above.
//div[#class='iradio_square-green']/input[#id='trip_0_date_0_flight_0_fare_0']/following-sibling::ins
For others radio buttons you just have to change the flight number.
Hope this helps...
:)

Related

Radio Buttons or checkbox with single selection on Datatables

I am using a datatable with checkboxes on the first column that permit multiple selection.
But now, I need that this checkboxes permit only single selection or it can be used a radio button on it.
This is the link to show my page http://cursosites-com-br.stackstaging.com/suporte_datatables.php
Can someone help me?
Regards,
Pedro
I found an example on the comments of this link (https://www.gyrocode.com/articles/jquery-datatables-row-selection-using-checkboxes-and-select-extension/comment-page-3/#comments)
Very good!

Watir clicking nested elements inside a container

I'm trying to complete a happy path e-commerce payment test but I cant seem to click on the nested element for credit card to be honest I'm not entirely sure which is the clickable element.
Any help to get this working would be appreciated.
When inputting forms, you typically want to interact with input and select elements. In this case, you can see that the visible input field is a radio button - ie <input type="radio">.
You access radio buttons using the radio method and select it by using the set method:
browser.radio(id: 'cc-payment').set
The element you want to click is the input with type radio. You should be able to do something like:
driver.find_element(:css, "input[id='cc-payment'][value='creditCard']").click
I'm curious if clicking on the parent item would resolve.
#browser.input(id: 'cc-payment').parent.click
If the div registers the click and sets the input then this might work. You should be able to manually verify this beahviour by clicking outside of the radial and seeing if it selects.

Multiselect option with remove item

I'm looking for a Qt/QML multiselect control that have a remove button.
I want to add a filter builder and I didn't find a good example or control for this purpose.
I can design token by myself. I'm just curious if someone already did that and can share it.
Multi filter selector
Thanks
A simple radio button for each option can do the job. If you do not include all these radio buttons under an exclusive group, a second click on these buttons deselects the option.
A click on the radio button includes selected option in the search results and second selection removes the option from the results.
An extra button which deselects all the radio buttons can also be added.
I don't intend to insult or disrespect you, but i think with radio buttons the task takes less time than posting this question.

How to select a Radio Button using Mechanize in Ruby?

i am building a crawler and i am using Mechanize. I wish to click on a radio button. How do i do that ?
Like for example there are two radio buttons say 'A' and 'B'.
The website automatically selects B, but i want 'A' using Mechanize in ruby. I am also using the latest version on Mechanize.
There are a couple of ways to do this. Probably the best would be to use the radio button's name or id:
form.radiobutton_with(:name => /b/).check
You could also do something like this:
form.radiobuttons.first.check
Which is more succinct, but more likely to break (if for instance you were to change the design of your form).
If you want to access a specific radio button out of a group of radio buttons, you can do so like this:
form.radiobutton_with(name: 'Choose wisely', value: 'Carpenter Goblet').check
This will allow you to choose the specific radio button with the desired value, this is better than selecting the radio button from its group using an index.

GUI: radio button group without selection?

Image a couple of objects for which one property can have 3 possible values. To edit them I want to use a radio button group with 3 buttons. If you have one object selected, it's obvious which radio button to select. But which what to select if multiple objects with different values of this property are selected? A radio button group without a selected radio button looks somewhat "naked".
One possible solution would be to add a 4th button to the group that indicates that the property is not set. You could have that one be the default when you need an 'indeterminate' default setting. This would allow the radio button group to start out with a selected radio button.
That being said, I'm having a hard time visualizing your situation. Do you think you could add some more detail to your question? I think you are talking about the default state of the radio buttons, but I'm not totally sure.
Hope this helps.

Resources