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.ArrayList;
19 import java.util.Arrays;
20 import java.util.List;
21
22 import org.eclipse.jetty.server.Server;
23 import org.htmlunit.WebDriverTestCase;
24 import org.htmlunit.WebServerTestCase;
25 import org.htmlunit.junit.annotation.Alerts;
26 import org.junit.jupiter.api.AfterAll;
27 import org.junit.jupiter.api.BeforeAll;
28 import org.junit.jupiter.api.Test;
29 import org.openqa.selenium.By;
30 import org.openqa.selenium.WebDriver;
31 import org.openqa.selenium.WebElement;
32
33
34
35
36
37
38
39
40
41 public class MooTools121Test extends WebDriverTestCase {
42
43 private static Server SERVER_;
44
45
46
47
48 @BeforeAll
49 public static void startSesrver() throws Exception {
50 SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/mootools/1.2.1", null);
51 }
52
53
54
55
56 @AfterAll
57 public static void stopServer() throws Exception {
58 if (SERVER_ != null) {
59 SERVER_.stop();
60 SERVER_.destroy();
61 SERVER_ = null;
62 }
63 }
64
65
66
67
68 @Alerts({"364", "1", "0",
69 "should return the function bound to an object with multiple arguments"})
70 @Test
71 public void mooTools() throws Exception {
72 final WebDriver driver = getWebDriver();
73 driver.get(URL_FIRST + "Specs/index.html");
74
75 driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(60));
76 driver.findElement(By.xpath("id('progress')[text() = '100']"));
77
78
79
80
81 final List<WebElement> failed = driver.findElements(By.xpath("//li[@class = 'exception']/h4"));
82 final List<String> failures = new ArrayList<>();
83 for (final WebElement elt : failed) {
84 failures.add(elt.getText());
85 }
86
87
88
89
90
91 assertEquals(Arrays.copyOfRange(getExpectedAlerts(), 3, getExpectedAlerts().length), failures);
92
93 assertEquals(getExpectedAlerts()[0], driver.findElement(By.id("total_examples")).getText());
94 assertEquals(getExpectedAlerts()[1], driver.findElement(By.id("total_failures")).getText());
95 assertEquals(getExpectedAlerts()[2], driver.findElement(By.id("total_errors")).getText());
96 }
97 }