1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.libraries;
16
17 import java.time.Duration;
18 import java.util.List;
19
20 import org.htmlunit.WebDriverTestCase;
21 import org.htmlunit.junit.annotation.Alerts;
22 import org.htmlunit.junit.annotation.HtmlUnitNYI;
23 import org.junit.jupiter.api.BeforeEach;
24 import org.junit.jupiter.api.Test;
25 import org.openqa.selenium.By;
26 import org.openqa.selenium.WebDriver;
27 import org.openqa.selenium.WebElement;
28
29
30
31
32
33
34
35
36
37
38
39 public class TinyMceTest extends WebDriverTestCase {
40
41
42
43
44 @Test
45 @Alerts({"348", "0"})
46 public void api() throws Exception {
47 test("api", Integer.parseInt(getExpectedAlerts()[0]), Integer.parseInt(getExpectedAlerts()[1]));
48 }
49
50
51
52
53 @Test
54 @Alerts(DEFAULT = {"89", "0"},
55 CHROME = {"89", "1"},
56 EDGE = {"89", "1"})
57 @HtmlUnitNYI(CHROME = {"70", "50"},
58 EDGE = {"70", "50"},
59 FF = {"70", "50"},
60 FF_ESR = {"70", "50"})
61 public void basic() throws Exception {
62 test("basic", Integer.parseInt(getExpectedAlerts()[0]), Integer.parseInt(getExpectedAlerts()[1]));
63 }
64
65 private void test(final String fileName, final int expectedTotal, final int expectedFailed) throws Exception {
66 final String url = URL_FIRST + "tests/" + fileName + ".html";
67 assertNotNull(url);
68
69 final WebDriver driver = getWebDriver();
70 driver.get(url);
71
72 driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
73 final WebElement result = driver.findElement(By.id("testresult"));
74 driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(0));
75
76 final WebElement totalSpan = result.findElement(By.xpath("./span[@class='all']"));
77 final int total = Integer.parseInt(totalSpan.getText());
78 assertEquals(expectedTotal, total);
79
80 final List<WebElement> failures = driver.findElements(By.xpath("//li[@class='fail']"));
81 final StringBuilder msg = new StringBuilder();
82 for (final WebElement failure : failures) {
83 msg.append(failure.getText());
84 msg.append("\n\n");
85 }
86
87 final WebElement failedSpan = result.findElement(By.xpath("./span[@class='bad']"));
88 final int failed = Integer.parseInt(failedSpan.getText());
89 assertEquals(expectedFailed, failed);
90 }
91
92
93
94
95
96 @BeforeEach
97 public void setUp() throws Exception {
98 startWebServer("src/test/resources/libraries/tinymce/3.2.7", null, null);
99 }
100 }