Greg Stone
Greg Stone

Reputation: 95

Changing span text with capybara

I've been using Capybara for 3 days now, and I have encountered a problem.

There is a html code:

<span id='some_id'> Text </span>

I need to change the Text with Capybara. Is it possible?

Upvotes: 3

Views: 1300

Answers (1)

Bill Turner
Bill Turner

Reputation: 3697

You should be able to use execute_script:

page.execute_script("$('span#some_id').html('New Text');")

This assumes you have JQuery. If not, then substitute the script inside to whatever framework you're using.

Upvotes: 5

Related Questions