Skip to content

Commit e9a90c3

Browse files
rbrishs96c
authored andcommitted
HtmlUnit: Fix getAttribute for dynamic properties.
Signed-off-by: Simon Stewart <[email protected]>
1 parent 8ed6975 commit e9a90c3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: java/client/src/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import net.sourceforge.htmlunit.corejs.javascript.Undefined;
2929

30+
import org.apache.commons.lang3.StringUtils;
3031
import org.openqa.selenium.By;
3132
import org.openqa.selenium.Dimension;
3233
import org.openqa.selenium.ElementNotVisibleException;
@@ -454,6 +455,14 @@ public String getAttribute(String name) {
454455
return "";
455456
}
456457

458+
final Object slotVal = element.getScriptObject().get(name);
459+
if (slotVal instanceof String) {
460+
String strVal = (String) slotVal;
461+
if (StringUtils.isNotEmpty(strVal)) {
462+
return strVal;
463+
}
464+
}
465+
457466
return null;
458467
}
459468

Diff for: java/client/test/org/openqa/selenium/ElementAttributeTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.junit.Test;
2121
import org.openqa.selenium.testing.Ignore;
2222
import org.openqa.selenium.testing.JUnit4TestBase;
23+
import org.openqa.selenium.testing.JavascriptEnabled;
2324

2425
import java.util.List;
2526

@@ -35,7 +36,6 @@
3536
import static org.junit.Assert.assertTrue;
3637
import static org.junit.Assert.fail;
3738
import static org.openqa.selenium.testing.Ignore.Driver.ANDROID;
38-
import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT;
3939
import static org.openqa.selenium.testing.Ignore.Driver.IE;
4040
import static org.openqa.selenium.testing.Ignore.Driver.IPHONE;
4141
import static org.openqa.selenium.testing.Ignore.Driver.MARIONETTE;
@@ -398,7 +398,7 @@ public void testMultipleAttributeShouldBeTrueWhenSelectHasMultipleWithValueAsSom
398398
assertEquals("true", element.getAttribute("multiple"));
399399
}
400400

401-
@Ignore({HTMLUNIT})
401+
@JavascriptEnabled
402402
@Test
403403
public void testGetAttributeOfUserDefinedProperty() {
404404
driver.get(pages.userDefinedProperty);

0 commit comments

Comments
 (0)