def test_element_list_contains_right_information_and_raises_right_exception(browser, app_url):
    "element list contains right information about query and raises nice exception message"
    browser.visit(app_url)
    with pytest.raises(ElementDoesNotExist) as err:
        element_list = browser.find_by_css(".element-that-dont-exists")
        assert "css" == element_list.find_by
        assert ".element-that-dont-exists" == element_list.query
        element_list.first

    expected_message = 'No elements were found with css ".element-that-dont-exists"'

    assert expected_message == err.value.args[0]
element list contains right information about query and raises nice exception message
tests/tests_webdriver/test_element_does_not_exist.py