Joseph Kouroma
Joseph Kouroma

Reputation: 78

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.

enter image description here

Upvotes: 0

Views: 552

Answers (3)

David Shute
David Shute

Reputation: 76

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.

Upvotes: 0

Justin Ko
Justin Ko

Reputation: 46836

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

Upvotes: 1

RemcoW
RemcoW

Reputation: 4326

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

Upvotes: 0

Related Questions