From 75417f5e3d32645859d94cec82255dc130ec4a2e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 18:55:34 +0200 Subject: Adding upstream version 2020.10.7. Signed-off-by: Daniel Baumann --- tests/selenium/qunit_test.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/selenium/qunit_test.py (limited to 'tests/selenium/qunit_test.py') diff --git a/tests/selenium/qunit_test.py b/tests/selenium/qunit_test.py new file mode 100644 index 0000000..f6afa4a --- /dev/null +++ b/tests/selenium/qunit_test.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +import unittest + +import pbtest + +from selenium.common.exceptions import TimeoutException + + +class QUnitTest(pbtest.PBSeleniumTest): + + def test_run_qunit_tests(self): + self.load_url(self.test_url) + + try: + # this text appears when tests finish running + self.txt_by_css( + "#qunit-testresult-display > span.total", + timeout=120 + ) + except TimeoutException as exc: + self.fail("Cannot find the results of QUnit tests %s" % exc) + + print("\nQUnit summary:") + print(self.txt_by_css("#qunit-testresult-display")) + + failed_test_els = self.driver.find_elements_by_css_selector( + ".fail .test-name" + ) + fail_msg = "The following QUnit tests failed:\n * {}".format( + "\n * ".join([el.text for el in failed_test_els]) + ) + + self.assertTrue(len(failed_test_els) == 0, msg=fail_msg) + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3