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