|
40 | 40 | * @author Sudhan Moghe |
41 | 41 | * @author Frank Danek |
42 | 42 | * @author Ronald Brill |
| 43 | + * @author Lai Quang Duong |
43 | 44 | */ |
44 | 45 | public class HtmlElement2Test extends WebDriverTestCase { |
45 | 46 |
|
@@ -491,4 +492,135 @@ public void setGetStyle() throws Exception { |
491 | 492 |
|
492 | 493 | loadPageVerifyTitle2(html); |
493 | 494 | } |
| 495 | + |
| 496 | + /** |
| 497 | + * @throws Exception if an error occurs |
| 498 | + */ |
| 499 | + @Test |
| 500 | + @Alerts("input[object HTMLInputElement]") |
| 501 | + public void typeFiresInputEvent() throws Exception { |
| 502 | + typeFiresInputEvent("text", "a"); |
| 503 | + typeFiresInputEvent("tel", "a"); |
| 504 | + typeFiresInputEvent("number", "1"); |
| 505 | + typeFiresInputEvent("search", "1"); |
| 506 | + typeFiresInputEvent("password", "7"); |
| 507 | + typeFiresInputEvent("email", "x"); |
| 508 | + typeFiresInputEvent("url", "h"); |
| 509 | + } |
| 510 | + |
| 511 | + /** |
| 512 | + * @throws Exception if an error occurs |
| 513 | + */ |
| 514 | + @Test |
| 515 | + @Alerts("input[object HTMLInputElement]") |
| 516 | + @HtmlUnitNYI( |
| 517 | + CHROME = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 518 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 519 | + EDGE = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 520 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 521 | + FF = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 522 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 523 | + FF_ESR = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 524 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]"}) |
| 525 | + public void typeFiresInputEventDate() throws Exception { |
| 526 | + // date and time are a bit tricky they only trigger if the input is correct |
| 527 | + typeFiresInputEvent("date", "01026"); |
| 528 | + } |
| 529 | + |
| 530 | + /** |
| 531 | + * @throws Exception if an error occurs |
| 532 | + */ |
| 533 | + @Test |
| 534 | + @Alerts("input[object HTMLInputElement]") |
| 535 | + @HtmlUnitNYI( |
| 536 | + CHROME = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 537 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 538 | + EDGE = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 539 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 540 | + FF = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 541 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 542 | + FF_ESR = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 543 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}) |
| 544 | + public void typeFiresInputEventTime() throws Exception { |
| 545 | + typeFiresInputEvent("time", "1122PM"); |
| 546 | + } |
| 547 | + |
| 548 | + /** |
| 549 | + * @throws Exception if an error occurs |
| 550 | + */ |
| 551 | + @Test |
| 552 | + @Alerts({"input[object HTMLInputElement]", "input[object HTMLInputElement]"}) |
| 553 | + public void typeFiresInputEventEachKey() throws Exception { |
| 554 | + typeFiresInputEvent("text", "ab"); |
| 555 | + typeFiresInputEvent("tel", "a1"); |
| 556 | + typeFiresInputEvent("number", "12"); |
| 557 | + typeFiresInputEvent("search", "1a"); |
| 558 | + typeFiresInputEvent("password", "7x"); |
| 559 | + typeFiresInputEvent("email", "xy"); |
| 560 | + typeFiresInputEvent("url", "ht"); |
| 561 | + } |
| 562 | + |
| 563 | + /** |
| 564 | + * @throws Exception if an error occurs |
| 565 | + */ |
| 566 | + @Test |
| 567 | + @Alerts(DEFAULT = {"input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 568 | + FF = "input[object HTMLInputElement]", |
| 569 | + FF_ESR = "input[object HTMLInputElement]") |
| 570 | + @HtmlUnitNYI( |
| 571 | + CHROME = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 572 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 573 | + EDGE = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 574 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 575 | + FF = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 576 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 577 | + FF_ESR = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 578 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}) |
| 579 | + public void typeFiresInputEventEachKeyDate() throws Exception { |
| 580 | + typeFiresInputEvent("date", "010268"); |
| 581 | + } |
| 582 | + |
| 583 | + /** |
| 584 | + * @throws Exception if an error occurs |
| 585 | + */ |
| 586 | + @Test |
| 587 | + @Alerts("input[object HTMLInputElement]") |
| 588 | + @HtmlUnitNYI( |
| 589 | + CHROME = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 590 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 591 | + EDGE = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 592 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 593 | + FF = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 594 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}, |
| 595 | + FF_ESR = {"input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]", |
| 596 | + "input[object HTMLInputElement]", "input[object HTMLInputElement]", "input[object HTMLInputElement]"}) |
| 597 | + public void typeFiresInputEventEachKeyTime() throws Exception { |
| 598 | + typeFiresInputEvent("time", "1122PM"); |
| 599 | + } |
| 600 | + |
| 601 | + /** |
| 602 | + * @throws Exception if an error occurs |
| 603 | + */ |
| 604 | + private void typeFiresInputEvent(String type, final String value) throws Exception { |
| 605 | + final String html = DOCTYPE_HTML |
| 606 | + + "<html>\n" |
| 607 | + + "<head>\n" |
| 608 | + + "<script>\n" |
| 609 | + + LOG_TITLE_FUNCTION |
| 610 | + + "</script>\n" |
| 611 | + + "</head>\n" |
| 612 | + + "<body>\n" |
| 613 | + + "<input type='" + type + "' id='t'>\n" |
| 614 | + + "<script>\n" |
| 615 | + + " document.getElementById('t').addEventListener('input', function(e) {\n" |
| 616 | + + " log('input' + e.target);\n" |
| 617 | + + " });\n" |
| 618 | + + "</script>\n" |
| 619 | + + "</body></html>"; |
| 620 | + |
| 621 | + final WebDriver driver = loadPage2(html); |
| 622 | + final WebElement div = driver.findElement(By.id("t")); |
| 623 | + div.sendKeys(value); |
| 624 | + verifyTitle2(driver, getExpectedAlerts()); |
| 625 | + } |
494 | 626 | } |
0 commit comments