Is it possible to interact with hidden elements with capybara?

前端 未结 7 934
孤街浪徒
孤街浪徒 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:55

    If the hidden element is nested in a visible parent element (e.g. a hidden input inside a visible label), you can click on the parent instead. If you still want to find the input by ID, you can traverse to the parent like so:

    find('#hidden_input').find(:xpath, '..').click
    

提交回复
热议问题