Search code examples
rubytestingautomationautomated-testscapybara

ruby - loop capybara click all elements


May you help me in this matter, pls? I would like to be able to delete all my files, but I would like to use a loop structure. How could I do this using the foreach in ruby, using the capybara? I've tried several posts and I did not get the expected result.

enter image description here

Delete File


Solution

  • Assuming there are no other buttons with the the class File__Button, you should be able to do something like:

    page.all(:css, 'button.File__Button').each do |button_element|
        button_element.click
    end
    

    If there is a confirmation, you will need to click that as well.