1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.libraries;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.annotation.Alerts;
19 import org.junit.jupiter.api.Test;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.WebDriver;
22 import org.openqa.selenium.WebElement;
23
24
25
26
27
28
29
30
31
32 public class Sarissa0993Test extends WebDriverTestCase {
33
34
35
36
37 @Test
38 @Alerts(CHROME = {"+++++++++++FF+++++", "+", "+", "+", "F++", "++", "++++F+++"},
39 EDGE = {"+++++++++++FF+++++", "+", "+", "+", "F++", "++", "++++F+++"},
40 FF = {"+++++++++++F++++++", "+", "+", "+", "F++", "++", "++++F+++"},
41 FF_ESR = {"+++++++++++F++++++", "+", "+", "+", "F++", "++", "++++F+++"})
42 public void sarissa() throws Exception {
43 startWebServer("src/test/resources/libraries/sarissa/0.9.9.3", null, null);
44 final String url = URL_FIRST + "test/testsarissa.html";
45
46 final WebDriver driver = getWebDriver();
47 driver.get(url);
48
49 driver.findElement(By.xpath("//button")).click();
50
51 driver.switchTo().alert().dismiss();
52
53 verify(driver, "SarissaTestCase", getExpectedAlerts()[0]);
54 verify(driver, "XmlHttpRequestTestCase", getExpectedAlerts()[1]);
55 verify(driver, "XMLSerializerTestCase", getExpectedAlerts()[2]);
56 verify(driver, "DOMParserTestCase", getExpectedAlerts()[3]);
57 verify(driver, "XMLDocumentTestCase", getExpectedAlerts()[4]);
58 verify(driver, "XMLElementTestCase", getExpectedAlerts()[5]);
59 verify(driver, "XSLTProcessorTestCase", getExpectedAlerts()[6]);
60 }
61
62
63
64
65
66 private static void verify(final WebDriver driver, final String testName, final String expectedResult) {
67 final WebElement div =
68 driver.findElement(By.xpath("//div[@class='placeholder' and a[@name='#" + testName + "']]"));
69
70 String text = div.getText();
71 text = text.substring(0, text.indexOf(String.valueOf(expectedResult.length()))).trim();
72 assertEquals(testName + " Results\n" + expectedResult, text);
73 }
74 }