1 package com.atlassian.webdriver.it.tests;
2
3 import com.atlassian.pageobjects.browser.Browser;
4 import com.atlassian.pageobjects.browser.IgnoreBrowser;
5 import com.atlassian.pageobjects.browser.RequireBrowser;
6 import com.atlassian.webdriver.it.AbstractFileBasedServerTest;
7 import com.atlassian.webdriver.it.pageobjects.page.contenteditable.ContentEditablePage;
8 import org.junit.Before;
9 import org.junit.Test;
10 import org.openqa.selenium.By;
11 import org.openqa.selenium.WebDriver;
12 import org.openqa.selenium.WebElement;
13
14 import static org.junit.Assert.assertFalse;
15 import static org.junit.Assert.assertTrue;
16
17 @IgnoreBrowser(value = {Browser.HTMLUNIT, Browser.HTMLUNIT_NOJS}, reason = "SELENIUM-165 HtmlUnit does not support contenteditable")
18 public class TestContentEditableBug extends AbstractFileBasedServerTest
19 {
20
21 ContentEditablePage contentEditablePage;
22 WebDriver driver;
23
24 @Before
25 public void init()
26 {
27 contentEditablePage = product.visit(ContentEditablePage.class);
28 driver = product.getTester().getDriver();
29 }
30
31 @Test
32 @IgnoreBrowser(value = { Browser.HTMLUNIT, Browser.HTMLUNIT_NOJS, Browser.CHROME }, reason = "Need to upgrade to Chrome 28 to fix")
33 public void testEditingContentEditableIframeWorks()
34 {
35 WebElement el = contentEditablePage.getContentEditable();
36 WebElement el2 = el.findElement(By.id("test"));
37 el2.click();
38 el2.sendKeys("HELLO");
39
40 assertTrue(el2.getText().contains("HELLO"));
41 }
42
43
44
45
46
47
48 @Test
49 @RequireBrowser(Browser.CHROME)
50 public void testEditingContentEditableIframeIsBrokenInChrome()
51 {
52 WebElement contentEditable = contentEditablePage.getContentEditable();
53 WebElement test = contentEditable.findElement(By.id("test"));
54 test.click();
55 test.sendKeys("HELLO");
56
57 assertFalse("Typing in contenteditable should not work in Chrome", test.getText().contains("HELLO"));
58 }
59
60 @Test
61 public void testEditingContentEditableDivWorks()
62 {
63 WebElement el = driver.findElement(By.id("div-ce"));
64 el.sendKeys("WORLD");
65 assertTrue(el.getText().contains("WORLD"));
66 }
67
68 }