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://vuejs.org/">Vue.js</a>.</p>
26   *
27   * @author Ronald Brill
28   */
29  public class VueTest extends WebDriverTestCase {
30  
31      /**
32       * @throws Exception if an error occurs
33       */
34      @Test
35      @Alerts("Hello World")
36      public void hello() throws Exception {
37          final String url = URL_FIRST + "hello.html";
38  
39          final WebDriver driver = getWebDriver();
40          driver.get(url);
41  
42          assertEquals(getExpectedAlerts()[0], driver.findElement(By.id("app")).getText());
43      }
44  
45      /**
46       * @throws Exception if an error occurs
47       */
48      @Test
49      @Alerts("Hello World")
50      public void helloMin() throws Exception {
51          final String url = URL_FIRST + "hello.min.html";
52  
53          final WebDriver driver = getWebDriver();
54          driver.get(url);
55  
56          assertEquals(getExpectedAlerts()[0], driver.findElement(By.id("app")).getText());
57      }
58  
59      /**
60       * @throws Exception if an error occurs
61       */
62      @Test
63      @Alerts("Hello from HtmlUnit!")
64      public void helloButton() throws Exception {
65          final String url = URL_FIRST + "hello_button.html";
66  
67          final WebDriver driver = getWebDriver();
68          driver.get(url);
69  
70          driver.findElement(By.id("tester")).click();
71          verifyAlerts(driver, getExpectedAlerts());
72      }
73  
74      /**
75       * @throws Exception if an error occurs
76       */
77      @Test
78      @Alerts("Hello from HtmlUnit!")
79      public void helloButtonMin() throws Exception {
80          final String url = URL_FIRST + "hello_button.min.html";
81  
82          final WebDriver driver = getWebDriver();
83          driver.get(url);
84  
85          driver.findElement(By.id("tester")).click();
86          verifyAlerts(driver, getExpectedAlerts());
87      }
88  
89      /**
90       * Performs pre-test initialization.
91       * @throws Exception if an error occurs
92       */
93      @BeforeEach
94      public void setUp() throws Exception {
95          startWebServer("src/test/resources/libraries/vue/hello_world", null, null);
96      }
97  }