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