Created
February 25, 2013 14:19
-
-
Save onemanbucket/5030082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package default; | |
import junit.framework.Assert; | |
import org.junit.Test; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.firefox.FirefoxProfile; | |
public class FirefoxContenteditableTest { | |
@Test | |
public void test() throws InterruptedException { | |
FirefoxProfile profile = new FirefoxProfile(); | |
profile.setPreference("webdriver.log.file", "/tmp/firefox_console"); | |
WebDriver driver = new FirefoxDriver(profile); | |
driver.navigate().to("http://localhost:1234/preview.html"); | |
// set breakpoint on the row below and step through the program | |
WebElement element = driver.findElement(By.xpath("//child::*[(self::h1 or self::a) and text()='erik1']/ancestor-or-self::div/div/div/p")); | |
element.click(); | |
element.sendKeys("hoj"); | |
Assert.assertEquals("hoj123", element.getText()); | |
} | |
} | |
-------- | |
preview.html | |
-------- | |
<html> | |
<body> | |
<div class="container"> | |
<div class="element"> | |
<div> | |
<h1 contenteditable="true">erik1</h1> | |
</div> | |
<div> | |
<div> | |
<p contenteditable="true">123</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment