Is it possible to interact with hidden elements with capybara?

前端 未结 7 935
孤街浪徒
孤街浪徒 2021-02-06 21:08

I have a file field that has opacity: 0 and is overlaping a fake button. Its a common css technic to fake a sort of \"Upload button\" that displays consistently acr

7条回答
  •  花落未央
    2021-02-06 21:49

    I ended up resolving it a different route.

    execute_script() was giving me a hard time (it would freeze test execution on FireFox), so this is what I did:

    I already had an appropriate javascript file. I appended the following

    <% if ENV["RAILS_ENV"] == "test" %>
      $('#photos').show()
    <% end %>
    

    I also had to append .erb to my javascript file for proper Rails asset handling.

    And in my test file, I was already setting ENV["RAILS_ENV"] = "test"

    This way I could just dumb down the UI for test, and yet maintain the look and feel for production.

提交回复
热议问题