[HtmlUnit] SVN: [14647] trunk/htmlunit/src

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[HtmlUnit] SVN: [14647] trunk/htmlunit/src

HtmlUnit - Dev mailing list
Revision: 14647
          http://sourceforge.net/p/htmlunit/code/14647
Author:   rbri
Date:     2017-07-07 08:35:55 +0000 (Fri, 07 Jul 2017)
Log Message:
-----------
more label fixes

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLabel.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlLabelTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLabel.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLabel.java 2017-07-05 06:17:20 UTC (rev 14646)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLabel.java 2017-07-07 08:35:55 UTC (rev 14647)
@@ -158,7 +158,7 @@
         // then the click on the referenced element
         final HtmlElement element = getReferencedElement();
         if (element != null) {
-            response = element.click(false, false, false, false, false, true);
+            response = element.click(false, false, false, false, true, true);
         }
         else {
             response = page;

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlLabelTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlLabelTest.java 2017-07-05 06:17:20 UTC (rev 14646)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlLabelTest.java 2017-07-07 08:35:55 UTC (rev 14647)
@@ -30,6 +30,7 @@
  * @author Marc Guillemot
  * @author Ahmed Ashour
  * @author Frank Danek
+ * @author Ronald Brill
  */
 @RunWith(BrowserRunner.class)
 public class HtmlLabelTest extends WebDriverTestCase {
@@ -77,6 +78,114 @@
      * @throws Exception if an error occurs
      */
     @Test
+    @Alerts({"click radio1Label", "click listItem1", "click list",
+                "click radio1", "click listItem1", "click list"})
+    public void triggerRadio() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='radio1Label' for='radio1' onclick='alert(\"click radio1Label\")'>Radio 1</label>\n"
+            + "    <input id='radio1' name='radios' value='1' type='radio' "
+                        + "onclick='alert(\"click radio1\");'>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"radio1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("radio1Label")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Alerts({"click radio1Label", "click listItem1", "click list",
+                "click radio1", "click listItem1", "click list"})
+    public void triggerRadioChecked() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='radio1Label' for='radio1' onclick='alert(\"click radio1Label\")'>Radio 1</label>\n"
+            + "    <input id='radio1' name='radios' value='1' type='radio' checked "
+                        + "onclick='alert(\"click radio1\");'>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"radio1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("radio1Label")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Alerts({"click radio1Label", "click listItem1", "click list",
+                "click radio1", "click listItem1", "click list"})
+    public void triggerRadioInvisible() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='radio1Label' for='radio1' onclick='alert(\"click radio1Label\")'>Radio 1</label>\n"
+            + "    <input id='radio1' name='radios' value='1' type='radio' style='display: none;' "
+                        + "onclick='alert(\"click radio1\");'>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"radio1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("radio1Label")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Alerts({"click radio1Label", "click listItem1", "click list",
+                "click radio1", "click listItem1", "click list"})
+    public void triggerRadioHidden() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='radio1Label' for='radio1' onclick='alert(\"click radio1Label\")'>Radio 1</label>\n"
+            + "    <input id='radio1' name='radios' value='1' type='radio' hidden "
+                        + "onclick='alert(\"click radio1\");'>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"radio1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("radio1Label")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
     @Alerts({"click span1", "click radio1Label", "click listItem1", "click list",
                 "click radio1", "click radio1Label",
                 "click listItem1", "click list"})
@@ -144,7 +253,7 @@
     @Alerts({"click span1", "click radio1Label", "click listItem1", "click list",
                 "click radio1", "click radio1Label",
                 "click listItem1", "click list"})
-    public void triggerRadioComplexCaseHidden() throws Exception {
+    public void triggerRadioComplexCaseInvisible() throws Exception {
         final String html = "<html>\n"
             + "<body>\n"
             + "  <ul onclick='alert(\"click list\")'>\n"
@@ -163,7 +272,7 @@
 
         final WebDriver driver = loadPage2(html);
         driver.findElement(By.id("radio1Span")).click();
-        verifyAlerts(2000000, driver, getExpectedAlerts());
+        verifyAlerts(driver, getExpectedAlerts());
 
         driver.findElement(By.id("check")).click();
         verifyAlerts(driver, "true");
@@ -173,6 +282,38 @@
      * @throws Exception if an error occurs
      */
     @Test
+    @Alerts({"click span1", "click radio1Label", "click listItem1", "click list",
+                "click radio1", "click radio1Label",
+                "click listItem1", "click list"})
+    public void triggerRadioComplexCaseHidden() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='radio1Label' for='radio1' onclick='alert(\"click radio1Label\")'>\n"
+            + "      <span>\n"
+            + "        <input id='radio1' name='radios' value='1' type='radio' hidden "
+                            + "onclick='alert(\"click radio1\");'>\n"
+            + "        <span id='radio1Span' onclick='alert(\"click span1\")'>Radio 1</span>\n"
+            + "      </span>\n"
+            + "    </label>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"radio1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("radio1Span")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
     @Alerts({"click span1", "click radio1Label", "click listItem1", "click list"})
     public void triggerRadioComplexCaseDisabled() throws Exception {
         final String html = "<html>\n"
@@ -259,6 +400,114 @@
      * @throws Exception if an error occurs
      */
     @Test
+    @Alerts({"click check1Label", "click listItem1", "click list",
+                "click check1", "click listItem1", "click list"})
+    public void triggerCheckbox() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='check1Label' for='check1' onclick='alert(\"click check1Label\")'>Checkbox 1</label>\n"
+            + "    <input id='check1' name='checks' value='1' type='checkbox' "
+                        + "onclick='alert(\"click check1\");'>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"check1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("check1Label")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Alerts({"click check1Label", "click listItem1", "click list",
+                "click check1", "click listItem1", "click list"})
+    public void triggerCheckboxChecked() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='check1Label' for='check1' onclick='alert(\"click check1Label\")'>Checkbox 1</label>\n"
+            + "    <input id='check1' name='checks' value='1' type='checkbox' checked "
+                        + "onclick='alert(\"click check1\");'>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"check1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("check1Label")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "false");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Alerts({"click check1Label", "click listItem1", "click list",
+                "click check1", "click listItem1", "click list"})
+    public void triggerCheckboxInvisible() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='check1Label' for='check1' onclick='alert(\"click check1Label\")'>Checkbox 1</label>\n"
+            + "    <input id='check1' name='checks' value='1' type='checkbox' style='display: none;' "
+                        + "onclick='alert(\"click check1\");'>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"check1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("check1Label")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Alerts({"click check1Label", "click listItem1", "click list",
+                "click check1", "click listItem1", "click list"})
+    public void triggerCheckboxHidden() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='check1Label' for='check1' onclick='alert(\"click check1Label\")'>Checkbox 1</label>\n"
+            + "    <input id='check1' name='checks' value='1' type='checkbox' hidden "
+                        + "onclick='alert(\"click check1\");'>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"check1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("check1Label")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
     @Alerts({"click span1", "click check1Label", "click listItem1", "click list",
                 "click check1", "click check1Label",
                 "click listItem1", "click list"})
@@ -326,7 +575,7 @@
     @Alerts({"click span1", "click check1Label", "click listItem1", "click list",
                 "click check1", "click check1Label",
                 "click listItem1", "click list"})
-    public void triggerCheckboxComplexCaseHidden() throws Exception {
+    public void triggerCheckboxComplexCaseInvisible() throws Exception {
         final String html = "<html>\n"
             + "<body>\n"
             + "  <ul onclick='alert(\"click list\")'>\n"
@@ -345,7 +594,7 @@
 
         final WebDriver driver = loadPage2(html);
         driver.findElement(By.id("check1Span")).click();
-        verifyAlerts(2000000, driver, getExpectedAlerts());
+        verifyAlerts(driver, getExpectedAlerts());
 
         driver.findElement(By.id("check")).click();
         verifyAlerts(driver, "true");
@@ -355,6 +604,38 @@
      * @throws Exception if an error occurs
      */
     @Test
+    @Alerts({"click span1", "click check1Label", "click listItem1", "click list",
+                "click check1", "click check1Label",
+                "click listItem1", "click list"})
+    public void triggerCheckboxComplexCaseHidden() throws Exception {
+        final String html = "<html>\n"
+            + "<body>\n"
+            + "  <ul onclick='alert(\"click list\")'>\n"
+            + "  <li onclick='alert(\"click listItem1\")'>\n"
+            + "    <label id='check1Label' for='check1' onclick='alert(\"click check1Label\")'>\n"
+            + "      <span>\n"
+            + "        <input id='check1' name='checks' value='1' type='checkbox' hidden "
+                            + "onclick='alert(\"click check1\");'>\n"
+            + "        <span id='check1Span' onclick='alert(\"click span1\")'>Checkbox 1</span>\n"
+            + "      </span>\n"
+            + "    </label>\n"
+            + "  </li>\n"
+            + "</ul>\n"
+            + "<button id='check' onclick='alert(document.getElementById(\"check1\").checked)'>Check</button>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPage2(html);
+        driver.findElement(By.id("check1Span")).click();
+        verifyAlerts(driver, getExpectedAlerts());
+
+        driver.findElement(By.id("check")).click();
+        verifyAlerts(driver, "true");
+    }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
     @Alerts({"click span1", "click check1Label", "click listItem1", "click list"})
     public void triggerCheckboxComplexCaseDisabled() throws Exception {
         final String html = "<html>\n"


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop