Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I print the content of a <span> in Cucumber / Capybara?

I want to print the content of a error message that is situated in a span and looks something like this:

<span>Es exisitiert bereits ein Account mit dieser E-Mail Adresse. Wenn Sie sich sicher sind, dass dies Ihre Adresse ist, dann klicken Sie <a href="https://link-removed.com">hier</a> um das Passwort und den Zugang zu Ihrem Account zu erhalten.</span>

In my step definition, I tried the following

print page.find('.error-msg span')

This, however, doesn't really work. After googling for an hour I couldn't find anything that worked, which may also be due to the fact that I am pretty much new to all of this.

I basically want to debug, so I want to see what the actual content is. It will also be helpful for future endeavours.

like image 483
TrashyMcTrash Avatar asked Sep 02 '25 06:09

TrashyMcTrash


1 Answers

You can call text against that.

puts page.find('.error-msg span').text

http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Element

like image 200
nowk Avatar answered Sep 04 '25 23:09

nowk