Reputation: 464
I can able to get the element through
page.find_button("Save", visible: :hidden, wait: 5)
But i can't trigger a click
page.find_button("Save", visible: :hidden, wait: 5).click
Upvotes: 0
Views: 628
Reputation: 49950
Because Capybara is primarily designed as a testing tool it attempts to emulate what a user could actually do. Since a user can't click on a non-visible button Capybara can't directly either. If you're testing you need to replicate what a user would do.
If, on the other hand, you're just automating a site to scrape some data and really want to trigger the click event you can try something like
page.find_button("Save", visible: :hidden, wait: 5).execute_script('this.click()')
Note: If you do that in code that is actually testing a site/app your test is basically worthless.
Upvotes: 2