File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
src/org/openqa/selenium/htmlunit Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 6
6
< h1 > Heading</ h1 >
7
7
8
8
< p id ="oneline "> A single line of text</ p >
9
+ < p id ="hiddenline " style ="visibility: hidden "> A hidden line of text</ p >
9
10
10
11
< div id ="multiline ">
11
12
< p > A div containing</ p >
Original file line number Diff line number Diff line change @@ -414,6 +414,10 @@ public String getAttribute(String name) {
414
414
return null ;
415
415
}
416
416
417
+ if ("textContent" .equalsIgnoreCase (lowerName )) {
418
+ return element .getTextContent ();
419
+ }
420
+
417
421
if ("value" .equals (lowerName )) {
418
422
if (element instanceof HtmlTextArea ) {
419
423
return ((HtmlTextArea ) element ).getText ();
Original file line number Diff line number Diff line change 21
21
import org .openqa .selenium .testing .Ignore ;
22
22
import org .openqa .selenium .testing .JUnit4TestBase ;
23
23
import org .openqa .selenium .testing .JavascriptEnabled ;
24
+ import org .openqa .selenium .testing .TestUtilities ;
24
25
25
26
import java .util .List ;
26
27
35
36
import static org .junit .Assert .assertThat ;
36
37
import static org .junit .Assert .assertTrue ;
37
38
import static org .junit .Assert .fail ;
39
+ import static org .junit .Assume .assumeFalse ;
38
40
import static org .openqa .selenium .testing .Ignore .Driver .IE ;
39
41
import static org .openqa .selenium .testing .Ignore .Driver .MARIONETTE ;
40
42
@@ -239,6 +241,18 @@ public void testShouldTreatReadonlyAsAValue() {
239
241
assertFalse (readonly .equals (notReadonly ));
240
242
}
241
243
244
+ @ Test
245
+ public void testShouldReturnHiddenTextForTextContentAttribute () {
246
+ assumeFalse ("IE before 9 doesn't handle textContent attribute" , TestUtilities .isOldIe (driver ));
247
+
248
+ driver .get (pages .simpleTestPage );
249
+
250
+ WebElement element = driver .findElement (By .id ("hiddenline" ));
251
+ String textContent = element .getAttribute ("textContent" );
252
+
253
+ assertEquals (textContent , "A hidden line of text" );
254
+ }
255
+
242
256
@ Test
243
257
public void testShouldGetNumericAtribute () {
244
258
driver .get (pages .formPage );
You can’t perform that action at this time.
0 commit comments