(final String fileName, final int expectedTotal, final int expectedFailed)
| 71 | } |
| 72 | |
| 73 | private void test(final String fileName, final int expectedTotal, final int expectedFailed) throws Exception { |
| 74 | final String url = URL_FIRST + "tests/" + fileName + ".html"; |
| 75 | assertNotNull(url); |
| 76 | |
| 77 | final WebDriver driver = getWebDriver(); |
| 78 | driver.get(url); |
| 79 | |
| 80 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); |
| 81 | final WebElement result = driver.findElement(By.id("testresult")); |
| 82 | driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(0)); |
| 83 | |
| 84 | final WebElement totalSpan = result.findElement(By.xpath("./span[@class='all']")); |
| 85 | final int total = Integer.parseInt(totalSpan.getText()); |
| 86 | assertEquals(expectedTotal, total); |
| 87 | |
| 88 | final List<WebElement> failures = driver.findElements(By.xpath("//li[@class='fail']")); |
| 89 | final StringBuilder msg = new StringBuilder(); |
| 90 | for (final WebElement failure : failures) { |
| 91 | msg.append(failure.getText()); |
| 92 | msg.append("\n\n"); |
| 93 | } |
| 94 | |
| 95 | final WebElement failedSpan = result.findElement(By.xpath("./span[@class='bad']")); |
| 96 | final int failed = Integer.parseInt(failedSpan.getText()); |
| 97 | assertEquals(expectedFailed, failed); |
| 98 | } |
| 99 | } |
no test coverage detected