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