Node::Element text returns string in uppercase, so has_css? fails

7 views
Skip to first unread message

Jose Miguel Gallas

unread,
Nov 17, 2022, 3:52:10 AM11/17/22
to Capybara
Hi there!
I've been struggling with this a while and can't quite figure out what's happening. We render certain flash alerts in our web app and there's a Cucumber step to assert the message. These messages are in normal case, however Capybara don't match them sometimes because it evaluates "visible" text as upper case. Example:

```
31] pry(#<Cucumber::Rails::World>)> find('#flash-messages').text(:all)
=> "× Credit card details were successfully stored."
[32] pry(#<Cucumber::Rails::World>)> find('#flash-messages').text(:visible)
=> "×\nCREDIT CARD DETAILS WERE SUCCESSFULLY STORED."
```
In the browser, the text looks just fine:
Screenshot 2022-11-17 at 09.48.02.png
Also:
```
> document.querySelector('#flash-messages .container').innerText
< "× Credit card details were successfully stored."
```

The project has 2 or 3 different ways to render these alerts (it's a very old project!) and this "upper case" problem doesn't always happen.

Any ideas / suggestions how to approach this?

Thomas Walpole

unread,
Nov 17, 2022, 9:36:21 AM11/17/22
to ruby-c...@googlegroups.com
What CSS is being applied to those messages?

--
You received this message because you are subscribed to the Google Groups "Capybara" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-capybar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-capybara/48c6ec2c-1ac9-48d3-88b2-c3b4b45e19c5n%40googlegroups.com.

Jose Miguel Gallas

unread,
Nov 17, 2022, 9:51:38 AM11/17/22
to ruby-c...@googlegroups.com
And now I feel embarrassed! Turns out the css makes it upper case. Capybara 1, Me 0.
Thanks for pointing this out @thomas!

JOSE MIGUEL GALLAS OLMEDO

senior Software Engineer, 3scale api management

Red Hat 

M: +34618488633    



You received this message because you are subscribed to a topic in the Google Groups "Capybara" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ruby-capybara/Ev4hn-Q0Kmw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ruby-capybar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-capybara/CAFKy59HonR2GZuAq3%3DKsspK7SQDx8zotFDcmmsr1qPvSTP0qhQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages