View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.libraries;
16  
17  import java.util.List;
18  
19  import org.htmlunit.WebServerTestCase;
20  import org.htmlunit.junit.BrowserRunner;
21  import org.junit.BeforeClass;
22  import org.junit.Test;
23  import org.junit.runner.RunWith;
24  import org.openqa.selenium.By;
25  import org.openqa.selenium.WebDriver;
26  import org.openqa.selenium.WebElement;
27  
28  /**
29   * Tests for compatibility with version 1.5.0-rc1 of
30   * <a href="http://www.prototypejs.org/">Prototype JavaScript library</a>.
31   *
32   * @author Daniel Gredler
33   * @author Ahmed Ashour
34   * @author Marc Guillemot
35   * @author Ronald Brill
36   */
37  @RunWith(BrowserRunner.class)
38  public class Prototype150rc1Test extends PrototypeTestBase {
39  
40      /**
41       * @throws Exception if an error occurs
42       */
43      @BeforeClass
44      public static void startSesrver() throws Exception {
45          SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/prototype/1.5.0-rc1/", null);
46      }
47  
48      /**
49       * {@inheritDoc}
50       */
51      @Override
52      protected String getVersion() {
53          return "1.5.0-rc1";
54      }
55  
56      /**
57       * @return the resource base url
58       */
59      @Override
60      protected String getBaseUrl() {
61          return URL_FIRST + "test/unit/";
62      }
63  
64      @Override
65      protected boolean testFinished(final WebDriver driver) {
66          final List<WebElement> status = driver.findElements(By.cssSelector("div#logsummary"));
67          for (final WebElement webElement : status) {
68              if (!webElement.getText().contains("errors")) {
69                  return false;
70              }
71          }
72          return true;
73      }
74  
75      /**
76       * @throws Exception if test fails
77       */
78      @Test
79      public void ajax() throws Exception {
80          test("ajax.html");
81      }
82  
83      /**
84       * @throws Exception if test fails
85       */
86      @Test
87      public void array() throws Exception {
88          test("array.html");
89      }
90  
91      /**
92       * @throws Exception if test fails
93       */
94      @Test
95      public void base() throws Exception {
96          test("base.html");
97      }
98  
99      /**
100      * @throws Exception if test fails
101      */
102     @Test
103     public void dom() throws Exception {
104         test("dom.html");
105     }
106 
107     /**
108      * @throws Exception if test fails
109      */
110     @Test
111     public void elementMixins() throws Exception {
112         test("element_mixins.html");
113     }
114 
115     /**
116      * @throws Exception if test fails
117      */
118     @Test
119     public void enumerable() throws Exception {
120         test("enumerable.html");
121     }
122 
123     /**
124      * @throws Exception if test fails
125      */
126     @Test
127     public void form() throws Exception {
128         test("form.html");
129     }
130 
131     /**
132      * @throws Exception if test fails
133      */
134     @Test
135     public void hash() throws Exception {
136         test("hash.html");
137     }
138 
139     /**
140      * @throws Exception if test fails
141      */
142     @Test
143     public void position() throws Exception {
144         test("position.html");
145     }
146 
147     /**
148      * @throws Exception if test fails
149      */
150     @Test
151     public void range() throws Exception {
152         test("range.html");
153     }
154 
155     /**
156      * @throws Exception if test fails
157      */
158     @Test
159     public void selector() throws Exception {
160         test("selector.html");
161     }
162 
163     /**
164      * @throws Exception if test fails
165      */
166     @Test
167     public void string() throws Exception {
168         test("string.html");
169     }
170 }