Testing Ruby on Rails application with RSpec, Capybara and Selenium.
I want to click an anchor which has an href but shouldn't lead anywhere due to the event.preventDefault. Nonetheless the link leads the test to the linked page instead of remaining on the current one.
My first impression is that Javascript isn't working. Besides for other tests I can see Firefox doing some stuff, but I can say the same thing for this specific test. Is there anything I'm missing?
If I test the page on the dummy app event.preventDefault works as intended.
Current test is:
describe "In field group editor, user", type: :feature do
let(:user) { User.first }
before(:context) do
@structure = create(:structure)
end
it "should be able to create a checkbox" do
sign_in user
# should be login page
save_and_open_page # and it is
path_to_structure = edit_structure_path( structure_id: @structure.slug )
visit path_to_structure
find "#add-new-setting"
# should be structure page
save_and_open_page # and it is
click_on "add-new-setting" # this should fire an ajax call and preventDefault link behaviour
# should be still structure page
save_and_open_page # instead capybara it's gone to the new setting page
# ...
end
end
Aucun commentaire:
Enregistrer un commentaire