Skip to content

Commit a3b32a3

Browse files
Toilallukeis
authored andcommitted
Add innerHTML attribute support to HtmlUnitDriver
Signed-off-by: Luke Inman-Semerau <luke.semerau@gmail.com>
1 parent 0108b8b commit a3b32a3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

java/client/src/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ public String getAttribute(String name) {
418418
return element.getTextContent();
419419
}
420420

421+
if ("innerHTML".equalsIgnoreCase(lowerName)) {
422+
return element.asXml();
423+
}
424+
421425
if ("value".equals(lowerName)) {
422426
if (element instanceof HtmlTextArea) {
423427
return ((HtmlTextArea) element).getText();

java/client/test/org/openqa/selenium/ElementAttributeTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.List;
2727

2828
import static org.hamcrest.Matchers.anyOf;
29+
import static org.hamcrest.Matchers.containsString;
2930
import static org.hamcrest.Matchers.equalTo;
3031
import static org.hamcrest.Matchers.is;
3132
import static org.hamcrest.Matchers.nullValue;
@@ -226,6 +227,14 @@ public void testShouldReturnTheContentsOfATextAreaAsItsValue() {
226227
assertThat(value, equalTo("Example text"));
227228
}
228229

230+
@Test
231+
public void testShouldReturnInnerHtml() {
232+
driver.get(pages.simpleTestPage);
233+
234+
String html = driver.findElement(By.id("wrappingtext")).getAttribute("innerHTML");
235+
assertThat(html, containsString("<tbody>"));
236+
}
237+
229238
@Test
230239
public void testShouldTreatReadonlyAsAValue() {
231240
driver.get(pages.formPage);

0 commit comments

Comments
 (0)