How can i make sure that certain assets (css and js) are loaded before test progresses?

322 Views Asked by At

I'm writing an integration test for a react-joyride tour that i've implemented. The tests are failing because many times, even though Selenium clicks on a button, the event that is associated with that button click ( onClick) is not triggered.

I think this is because the js files for that particular button have not yet been loaded. How can i make sure that this these files are loaded before the execution is continued.

Code :

The following is my test.rb file.

#floatingButton -> button that starts the tour,

div.__floater__body -> div that contains the joyride tooltip

      wait_until { find(:css, '#floatingButton') }
      find(:css, '#floatingButton').click
      find(:css, 'div.__floater__body')
      within(:css, 'div.__floater__body') do
        # STEP 1
        assert page.has_content? 'An event is a date on which a particular test can be taken.'
        assert page.has_button? 'Close tour'

        assert page.has_button? 'Next'
        click_on 'Next'

        # STEP 2
        assert page.has_content? 'You can click here to create a new event.'
        assert page.has_button? 'Close tour'
        assert page.has_button? 'Next'
        assert page.has_button? 'Back'
        click_on 'Next'

Sometimes, when 'Next' is clicked nothing happens. The tour does not move to the next step.

enter image description here enter image description here

I'm sometimes getting the same problem with 'Back' and 'Close tour'(see image) buttons during testing.

How can i resolve this error. Please help!

0

There are 0 best solutions below