2

This is confusing me and my technology stack is so large at this point that I'm really struggling to debug anything.

I'm using Python 2.7, py.test, and the pytest-selenium, pytest-flask fixtures. I'm also using a couple of my own fixtures for things like customising selenium and easily creating DB objects.

I have a functional test suite that uses Selenium. I'm running my suite using BrowserStack (via local tunneling) and I want to run everything on lots of different browsers.

I have 4 tests that cannot pass at the moment, I'm waiting on some sandbox credentials for a third party service. Those tests will result in the server returning a 500 Internal Server Error. I've marked them in py.test as being expected to fail (i.e. @pytest.mark.xfail).

When I run the suite using Chrome everything works as expected. When I run it using Firefox the test hangs after it's failed. BrowserStack is showing that the test session has been closed properly so it's not a problem with BrowserStack hanging on a dodgy browser (at least I don't think it is).

If I remove the problematic tests then Firefox continues as it should. If I mark the tests as skipped (as opposed to xfail) then everything works as it should. If I mark a different test as xfail then everything continues as it should.

So it's something to do with that test and that browser, but not at the BrowserStack level. The only major thing different about the awkward tests is that they involve committing objects to the test DB. But the tests don't hang at the DB commands, they hang after the DB setup, after the 500 error page, but before the DB assertions. And it can't be the DB commands because they work if I'm using a different browser!

Here's one of the annoying test cases:

def test_upload_logo(db, selenium):
    u = db.create_user(...) # Customise user to use third party service
    selenium.signin(user=u)
    selenium.get('/awards/create/')
    ... # Run some normal web site tests, click this, type that there, etc.
    selenium.find('input[type="submit"]').click() # This results in the 500 error
    selenium.wait(locate='body.awards.retrieve') # This will fail because the browser is showing the 500 error page
    # The test never gets this far with Firefox because it hangs
    a = Award.query.all()
    assert 1 == len(a)

The selenium.wait command is a custom function that waits for the element located by the CSS selector to appear. I'm using this because browsers like IE and Edge don't implicitly wait after a click() (like Chrome does).

I'm not even sure where to start looking for how to fix this.

WilliamMayor
  • 745
  • 6
  • 15

0 Answers0