user3897533
user3897533

Reputation: 477

Capybara - select an option based on Partial text

I have an option value on page as - RMSOrg (Initializing)

Initializing as a text goes away after some validations. In automation I am just passing RMSOrg. How do I select the option based on partial text?

This syntax does not work

find('#organisation_id').find("option[contains(.,'#{@orgname}')]").select_option

@orgname has value RMSOrg. Initializing as a text goes away after a while so cannot time when it goes away so I have to select by partial text.. is it possible?

Upvotes: 0

Views: 501

Answers (1)

Thomas Walpole
Thomas Walpole

Reputation: 49880

find('#organisation_id').select('RMSOrg', exact: false)

Should do what you want, and if #organisation_id is the actual select element you can just do

select('RMSOrg', from: 'organisation_id', exact: false)

Upvotes: 1

Related Questions