| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
import unittest |
| 4 |
|
| 5 |
import pbtest |
| 6 |
|
| 7 |
from selenium.common.exceptions import TimeoutException |
| 8 |
from selenium.webdriver.common.by import By |
| 9 |
|
| 10 |
|
| 11 |
class QUnitTest(pbtest.PBSeleniumTest): |
| 12 |
|
| 13 |
def test_run_qunit_tests(self): |
| 14 |
self.load_url(self.test_url) |
| 15 |
|
| 16 |
try: |
| 17 |
# this text appears when tests finish running |
| 18 |
self.txt_by_css( |
| 19 |
"#qunit-testresult-display > span.total", |
| 20 |
timeout=120 |
| 21 |
) |
| 22 |
except TimeoutException as exc: |
| 23 |
self.fail(f"Cannot find the results of QUnit tests {exc}") |
| 24 |
|
| 25 |
print("\nQUnit summary:") |
| 26 |
print(self.txt_by_css("#qunit-testresult-display")) |
| 27 |
|
| 28 |
failed_test_els = self.driver.find_elements(By.CSS_SELECTOR, |
| 29 |
".fail .test-name") |
| 30 |
fail_msg = "The following QUnit tests failed:\n * {}".format( |
| 31 |
"\n * ".join([el.text for el in failed_test_els]) |
| 32 |
) |
| 33 |
|
| 34 |
assert not failed_test_els, fail_msg |
| 35 |
|
| 36 |
|
| 37 |
if __name__ == "__main__": |
| 38 |
unittest.main() |