Search in sources :

Example 21 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HtmlNumberInputTest method typeInvalidChars.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = { "--null-true", "4", "4--null-true", "4", "4--null-true" }, FF = { "--null-true", "4", "4--null-true", "", "--null-false" }, FF_ESR = { "--null-true", "4", "4--null-true", "", "--null-false" }, IE = { "--null-true", "4", "4--null-true", "4a", "4a--null-true" })
@HtmlUnitNYI(FF = { "--null-true", "4", "4--null-true", "4a", "--null-false" }, FF_ESR = { "--null-true", "4", "4--null-true", "4a", "--null-false" }, IE = { "--null-true", "4", "4--null-true", "4a", "--null-false" })
public void typeInvalidChars() throws Exception {
    final String html = "<html><head>\n" + "<script>\n" + "  function test() {\n" + "    var input = document.getElementById('testId');\n" + "    document.title = input.value + '-' " + "+ input.defaultValue + '-' " + "+ input.getAttribute('value')+ '-' " + "+ input.checkValidity();\n" + "  }\n" + "</script>\n" + "</head><body onload='test()'>\n" + "<form>\n" + "  <input type='number' id='testId'>\n" + "  <input type='button' id='testBtn' onclick='test()' >\n" + "</form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    assertEquals(getExpectedAlerts()[0], driver.getTitle());
    final WebElement t = driver.findElement(By.id("testId"));
    t.sendKeys(Keys.END, "4");
    assertEquals(getExpectedAlerts()[1], t.getAttribute("value"));
    driver.findElement(By.id("testBtn")).click();
    assertEquals(getExpectedAlerts()[2], driver.getTitle());
    t.sendKeys(Keys.END, "a");
    assertEquals(getExpectedAlerts()[3], t.getAttribute("value"));
    driver.findElement(By.id("testBtn")).click();
    assertEquals(getExpectedAlerts()[4], driver.getTitle());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 22 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HtmlLabelTest method clickForAndNestedEventBubbling.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "labelclick:label1", "parentclick:label1", "text1focus:text1", "text1click:text1", "labelclick:text1", "parentclick:text1" }, IE = { "labelclick:label1", "parentclick:label1", "text1click:text1", "labelclick:text1", "parentclick:text1", "text1focus:text1" })
@HtmlUnitNYI(IE = { "labelclick:label1", "parentclick:label1", "text1focus:text1", "text1click:text1", "labelclick:text1", "parentclick:text1" })
public void clickForAndNestedEventBubbling() throws Exception {
    final String html = "  <div onclick='log(\"parentclick:\" + event.target.id)' " + "onfocus='log(\"parentfocus:\" + event.target.id)'>\n" + "    <label id='label1' for='text1' onclick='log(\"labelclick:\" + event.target.id)' " + "onfocus='log(\"labelfocus:\" + event.target.id)'>Click me" + // we have to add some extra text to make Selenium click the label and not the nested element
    " (we have to add some extra text to make Selenium click the label and not the nested element)\n" + "      <input type='text' id='text1' onclick='log(\"text1click:\" + event.target.id)' " + "onfocus='log(\"text1focus:\" + event.target.id)'>\n" + "      <input type='text' id='text2' onclick='log(\"text2click:\" + event.target.id)' " + "onfocus='log(\"text2focus:\" + event.target.id)'>\n" + "    </label>\n" + "  </div>\n";
    final WebDriver driver = loadPage2(generatePage(html));
    driver.findElement(By.id("label1")).click();
    verifyTitle2(driver, getExpectedAlerts());
    assertEquals(driver.findElement(By.id("text1")), driver.switchTo().activeElement());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 23 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HtmlLabelTest method clickNestedInput.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "labelclick", "text1focus", "text1click", "labelclick" }, IE = { "labelclick", "text1click", "labelclick", "text1focus" })
@HtmlUnitNYI(IE = { "labelclick", "text1focus", "text1click", "labelclick" })
public void clickNestedInput() throws Exception {
    final String html = "  <label id='label1' onclick='log(\"labelclick\")' onfocus='log(\"labelfocus\")'>Click me" + // we have to add some extra text to make Selenium click the label and not the nested element
    " (we have to add some extra text to make Selenium click the label and not the nested element)\n" + "    <input type='text' id='text1' onclick='log(\"text1click\")' onfocus='log(\"text1focus\")'>\n" + "    <input type='text' id='text2' onclick='log(\"text2click\")' onfocus='log(\"text2focus\")'>\n" + "  </label>\n";
    final WebDriver driver = loadPage2(generatePage(html));
    driver.findElement(By.id("label1")).click();
    verifyTitle2(driver, getExpectedAlerts());
    assertEquals(driver.findElement(By.id("text1")), driver.switchTo().activeElement());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 24 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HtmlLabelTest method clickNestedSelect.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "labelclick", "select1focus", "select1click", "labelclick" }, IE = { "labelclick", "select1click", "labelclick", "select1focus" })
@HtmlUnitNYI(IE = { "labelclick", "select1focus", "select1click", "labelclick" })
public void clickNestedSelect() throws Exception {
    final String html = "  <label id='label1' onclick='log(\"labelclick\")' onfocus='log(\"labelfocus\")'>Click me" + // we have to add some extra text to make Selenium click the label and not the nested element
    " (we have to add some extra text to make Selenium click the label and not the nested element)\n" + "    <select id='select1' onclick='log(\"select1click\")' " + "onfocus='log(\"select1focus\")'><option>Option</option></select>\n" + "    <select id='select2' onclick='log(\"select2click\")' " + "onfocus='log(\"select2focus\")'><option>Option</option></select>\n" + "  </label>\n";
    final WebDriver driver = loadPage2(generatePage(html));
    driver.findElement(By.id("label1")).click();
    verifyTitle2(driver, getExpectedAlerts());
    assertEquals(driver.findElement(By.id("select1")), driver.switchTo().activeElement());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 25 with HtmlUnitNYI

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.

the class HtmlLabelTest method clickForTextArea.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = { "labelclick", "textfocus", "textclick" }, IE = { "labelclick", "textclick", "textfocus" })
@HtmlUnitNYI(IE = { "labelclick", "textfocus", "textclick" })
public void clickForTextArea() throws Exception {
    final String html = "  <label id='label1' for='text1' onclick='log(\"labelclick\")' " + "onfocus='log(\"labelfocus\")'>Click me</label>\n" + "  <textarea id='text1' onclick='log(\"textclick\")' " + "onfocus='log(\"textfocus\")'></textarea>\n";
    final WebDriver driver = loadPage2(generatePage(html));
    driver.findElement(By.id("label1")).click();
    verifyTitle2(driver, getExpectedAlerts());
    assertEquals(driver.findElement(By.id("text1")), driver.switchTo().activeElement());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Aggregations

Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)72 HtmlUnitNYI (com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)72 Test (org.junit.Test)68 WebDriver (org.openqa.selenium.WebDriver)54 HtmlPageTest (com.gargoylesoftware.htmlunit.html.HtmlPageTest)14 URL (java.net.URL)14 WebElement (org.openqa.selenium.WebElement)14 BuggyWebDriver (com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver)11 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)9 ArrayList (java.util.ArrayList)7 InputStream (java.io.InputStream)5 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)5 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 Servlet (javax.servlet.Servlet)2 HttpServlet (javax.servlet.http.HttpServlet)2 Page (com.gargoylesoftware.htmlunit.Page)1 UnexpectedPage (com.gargoylesoftware.htmlunit.UnexpectedPage)1 WebWindow (com.gargoylesoftware.htmlunit.WebWindow)1 DomNode (com.gargoylesoftware.htmlunit.html.DomNode)1