Suggestions for getting Selenium to play nice with Bootstrap modal fade?

后端 未结 7 1139
[愿得一人]
[愿得一人] 2021-02-05 19:45

I\'m working to live life the BDD way. I\'m using Cucumber (with Selenium) and happen to be using Twitter Bootstrap modals in my application.

While running Cucumber tes

相关标签:
7条回答
  • 2021-02-05 20:08

    What I generally do is assert against some content that should be visible on the modal (or not visible when it is fading out):

    expect(page).to have_content('My Modal Header')
    expect(page).to have_no_content('My Modal Header')
    

    It's important to use .to have_no_content and not .not_to have_content, as have_no_content will wait for a period for the thing to be true.

    In a pinch, you can also check for modal CSS selectors. Bootstrap adds an in class when the modal is visible:

    expect(page).to have_selector('.modal.in')
    expect(page).to have_no_selector('.modal.in')
    
    0 讨论(0)
提交回复
热议问题