"<<ERROR>>" being returned to describe :link_or_button

4 views
Skip to first unread message

Tim Diggins

unread,
Mar 13, 2023, 1:09:00 PMMar 13
to Capybara
Hi all

I've got a js/selenium spec (with headless chrome)  that has the following line that is flakey (fails on most but not all runs - and when I run it 10 times in a row it will always fail at least once ) with a line like the following

expect(page).to have_selector(:link_or_button, text: "Some button")

When it fails it gives this mystifying response:

expected to find visible link or button nil with text "Some button"
but there were no matches. Also found "<<ERROR>>", "<<ERROR>>", "<<ERROR>>",
"<<ERROR>>", "<<ERROR>>", "<<ERROR>>", "<<ERROR>>", "<<ERROR>>", "<<ERROR>>",
... many similar ...
"<<ERROR>>", "<<ERROR>>", "<<ERROR>>", "<<ERROR>>", "<<ERROR>>", "<<ERROR>>",
which matched the selector but not all filters.

I don't really understand why Selenium/Chrome would output <<Error>> rather than the text of the link or button (but it seems to imply that there has been a genuine error somewhere). FYI the html and png screenshots, both show the "Some button" button.

By passing the name as the direct argument rather than as text:, I can get fix the error and get it to pass (10 times in a row), ie:

expect(page).to have_selector(:link_or_button, "Some button")

This means (if I understand it correctly) the problem (the <<ERROR>> in fact) is coming from some communication with Chrome - any ideas what this would be, or how to debug it? 

many thanks

Tim
Reply all
Reply to author
Forward
0 new messages