Search in sources :

Example 86 with Alerts

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

the class HtmlRangeInputTest method clearInput.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("50")
public void clearInput() throws Exception {
    final String html = "<html>\n" + "<body>\n" + "<form>\n" + "  <input type='range' id='tester' value='42'>\n" + "</form>\n" + "</body>\n" + "</html>";
    final WebDriver driver = loadPage2(html);
    final WebElement element = driver.findElement(By.id("tester"));
    element.clear();
    assertEquals(getExpectedAlerts()[0], element.getAttribute("value"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 87 with Alerts

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

the class HtmlResetInput2Test method onclickDisables.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts({ "foo", "foonewValue", "foonewValue" })
public void onclickDisables() throws Exception {
    final String html = "<html><head>\n" + "  <script type='text/javascript'>\n" + "    function submitForm() {\n" + "      document.deliveryChannelForm.resetBtn.disabled = true;\n" + "    }\n" + "  </script>\n" + "</head>\n" + "<body>\n" + "  <form action='test' name='deliveryChannelForm'>\n" + "    <input type='text' id='textfield' value='foo'/>\n" + "    <input name='resetBtn' type='reset' value='Save' title='Save' onclick='submitForm();'>\n" + "  </form>" + "</script>\n" + "</body></html>";
    final WebDriver webDriver = loadPage2(html);
    final WebElement textfield = webDriver.findElement(By.id("textfield"));
    assertEquals(getExpectedAlerts()[0], textfield.getAttribute("value"));
    textfield.sendKeys("newValue");
    assertEquals(getExpectedAlerts()[1], textfield.getAttribute("value"));
    final WebElement reset = webDriver.findElement(By.name("resetBtn"));
    reset.click();
    assertEquals(getExpectedAlerts()[2], textfield.getAttribute("value"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 88 with Alerts

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

the class HtmlResetInput2Test method reset.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts({ "foo", "foonewValue", "foo" })
public void reset() throws Exception {
    final String html = "<html><head>\n" + "  <script type='text/javascript'>\n" + "    function submitForm() {\n" + "    }\n" + "  </script>\n" + "</head>\n" + "<body>\n" + "  <form action='test' name='deliveryChannelForm'>\n" + "    <input type='text' id='textfield' value='foo'/>\n" + "    <input name='resetBtn' type='reset' value='Save' title='Save' onclick='submitForm();'>\n" + "  </form>" + "</script>\n" + "</body></html>";
    final WebDriver webDriver = loadPage2(html);
    final WebElement textfield = webDriver.findElement(By.id("textfield"));
    assertEquals(getExpectedAlerts()[0], textfield.getAttribute("value"));
    textfield.sendKeys("newValue");
    assertEquals(getExpectedAlerts()[1], textfield.getAttribute("value"));
    final WebElement reset = webDriver.findElement(By.name("resetBtn"));
    reset.click();
    assertEquals(getExpectedAlerts()[2], textfield.getAttribute("value"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 89 with Alerts

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

the class HtmlPasswordInputTest method minLengthValidationValid.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts({ "abcdefghi", "§§URL§§second/", "2" })
public void minLengthValidationValid() throws Exception {
    final String html = "<!DOCTYPE html>\n" + "<html><head></head>\n" + "<body>\n" + "  <form id='myForm' action='" + URL_SECOND + "' method='" + HttpMethod.POST + "'>\n" + "    <input type='password' minlength='5' id='foo'>\n" + "    <button id='myButton' type='submit'>Submit</button>\n" + "  </form>\n" + "</body></html>";
    final String secondContent = "<html><head><title>second</title></head><body>\n" + "  <p>hello world</p>\n" + "</body></html>";
    getMockWebConnection().setResponse(URL_SECOND, secondContent);
    expandExpectedAlertsVariables(URL_FIRST);
    final WebDriver driver = loadPage2(html, URL_FIRST);
    final WebElement foo = driver.findElement(By.id("foo"));
    foo.sendKeys("abcdefghi");
    assertEquals(getExpectedAlerts()[0], foo.getAttribute("value"));
    // valid data
    driver.findElement(By.id("myButton")).click();
    assertEquals(getExpectedAlerts()[1], getMockWebConnection().getLastWebRequest().getUrl());
    assertEquals(Integer.parseInt(getExpectedAlerts()[2]), getMockWebConnection().getRequestCount());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 90 with Alerts

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

the class HtmlPasswordInputTest method typeDoesNotChangeValueAttribute.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts({ "null", "null" })
public void typeDoesNotChangeValueAttribute() throws Exception {
    final String html = "<html>\n" + "<head></head>\n" + "<body>\n" + "  <input type='password' id='p'/>\n" + "  <button id='check' onclick='alert(document.getElementById(\"p\").getAttribute(\"value\"));'>" + "DoIt</button>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    final WebElement p = driver.findElement(By.id("p"));
    final WebElement check = driver.findElement(By.id("check"));
    check.click();
    verifyAlerts(driver, getExpectedAlerts()[0]);
    p.sendKeys("abc");
    check.click();
    verifyAlerts(driver, getExpectedAlerts()[1]);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Aggregations

Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)1266 Test (org.junit.Test)1261 WebDriver (org.openqa.selenium.WebDriver)894 HtmlPageTest (com.gargoylesoftware.htmlunit.html.HtmlPageTest)398 URL (java.net.URL)238 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)206 BuggyWebDriver (com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver)159 WebElement (org.openqa.selenium.WebElement)146 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)128 MSXMLTestHelper.callLoadXMLDOMDocumentFromString (com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLTestHelper.callLoadXMLDOMDocumentFromString)101 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)97 ArrayList (java.util.ArrayList)90 HtmlUnitNYI (com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)72 NotYetImplemented (com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented)54 MockWebConnection (com.gargoylesoftware.htmlunit.MockWebConnection)48 XMLDocumentTest.callLoadXMLDocumentFromString (com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocumentTest.callLoadXMLDocumentFromString)47 XMLDocumentTest.callSerializeXMLDocumentToString (com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocumentTest.callSerializeXMLDocumentToString)44 File (java.io.File)30 WebClient (com.gargoylesoftware.htmlunit.WebClient)29 InputStream (java.io.InputStream)29