diff --git a/java/client/src/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java b/java/client/src/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java index 3d7d6eec95e10..dcf081d11c2cb 100644 --- a/java/client/src/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java +++ b/java/client/src/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java @@ -27,6 +27,7 @@ import net.sourceforge.htmlunit.corejs.javascript.Undefined; +import org.apache.commons.lang3.StringUtils; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; import org.openqa.selenium.ElementNotVisibleException; @@ -454,6 +455,14 @@ public String getAttribute(String name) { return ""; } + final Object slotVal = element.getScriptObject().get(name); + if (slotVal instanceof String) { + String strVal = (String) slotVal; + if (StringUtils.isNotEmpty(strVal)) { + return strVal; + } + } + return null; } diff --git a/java/client/test/org/openqa/selenium/ElementAttributeTest.java b/java/client/test/org/openqa/selenium/ElementAttributeTest.java index 830f1c637eeff..22f419f99b58c 100644 --- a/java/client/test/org/openqa/selenium/ElementAttributeTest.java +++ b/java/client/test/org/openqa/selenium/ElementAttributeTest.java @@ -20,6 +20,7 @@ import org.junit.Test; import org.openqa.selenium.testing.Ignore; import org.openqa.selenium.testing.JUnit4TestBase; +import org.openqa.selenium.testing.JavascriptEnabled; import java.util.List; @@ -35,7 +36,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.openqa.selenium.testing.Ignore.Driver.ANDROID; -import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT; import static org.openqa.selenium.testing.Ignore.Driver.IE; import static org.openqa.selenium.testing.Ignore.Driver.IPHONE; import static org.openqa.selenium.testing.Ignore.Driver.MARIONETTE; @@ -398,7 +398,7 @@ public void testMultipleAttributeShouldBeTrueWhenSelectHasMultipleWithValueAsSom assertEquals("true", element.getAttribute("multiple")); } - @Ignore({HTMLUNIT}) + @JavascriptEnabled @Test public void testGetAttributeOfUserDefinedProperty() { driver.get(pages.userDefinedProperty);