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 org.htmlunit.WebDriverTestCase;
18  import org.htmlunit.junit.annotation.Alerts;
19  import org.junit.jupiter.api.BeforeEach;
20  import org.junit.jupiter.api.Test;
21  import org.openqa.selenium.By;
22  import org.openqa.selenium.WebDriver;
23  
24  /**
25   * <p>Tests for <a href="https://www.polymer-project.org/">www.polymer-project.org</a>.</p>
26   *
27   * @author Ronald Brill
28   */
29  public class PolymerWebComponentsTest extends WebDriverTestCase {
30  
31      /**
32       * See https://github.com/HtmlUnit/htmlunit/issues/23.
33       *
34       * @throws Exception if an error occurs
35       */
36      @Test
37      @Alerts("Hello Unicorn :)")
38      public void hello() throws Exception {
39          final String url = URL_FIRST + "index.html";
40  
41          final WebDriver driver = getWebDriver();
42          driver.get(url);
43  
44          verify(() -> driver.findElement(By.tagName("body")).getText(), getExpectedAlerts()[0]);
45      }
46  
47      /**
48       * Performs pre-test initialization.
49       * @throws Exception if an error occurs
50       */
51      @BeforeEach
52      public void setUp() throws Exception {
53          startWebServer("src/test/resources/libraries/polymer/0_6_1", null, null);
54      }
55  }