cuprite
cuprite copied to clipboard
Replace \t for " " ?
I've been working recently on adopting cuprite in a big rails app. One thing that triggered many test failures was that the tab char is still present in the page body when asserting, for example:
Failure/Error: expect(page).to have_text('TOTAL £ 239.18')
expected to find text "TOTAL £ 239.18" in "Voucher successfully added\n+44 203 5148 622\nAccount\nCart\nCheckout\nOrder finished\nYour order\n10 × Producto num. 1 / en\nMate Big A7\n\t\n£ 197.83\n £ 181.34\nSubtotal\t\n£ 197.83\n £ 181.34\nStandard to Spain\t£ 16.33\nVAT 21 %\t£ 41.51\nTOTAL\t£ 239.18\nVoucher: PROMO1\nProceed to checkout\nProducto num. 1 / en\n10 buttons, 1 design\nEdit design\nAdd another design"
Selenium was stripping those chars away, but now the text is "TOTAL\t£ 239.18" instead of "TOTAL £ 239.18".
This is fixed by adding .gsub(/\t+/, " ")
in Node#visible_text
, as i've patched for now.
This seems like a reasonable thing to do, given that the same method is already transforming other chars. What do you think? i'll submit a PR if you agree with the change.
Hi @rogercampos, completely agree though perhaps it is better to do in index.js on JS. Sure go ahead!
@rogercampos I was able to avoid adding gsub
or actually changing the text in the expectations by enabling this setting on rails_helper.rb
:
Capybara.default_normalize_ws = true
That setting got rid of all of the extra whitespace characters.