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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations