Skip to content

Commit

Permalink
HtmlUnit: Fix getAttribute for dynamic properties.
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Stewart <[email protected]>
  • Loading branch information
rbri authored and shs96c committed Sep 29, 2014
1 parent 8ed6975 commit e9a90c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -398,7 +398,7 @@ public void testMultipleAttributeShouldBeTrueWhenSelectHasMultipleWithValueAsSom
assertEquals("true", element.getAttribute("multiple"));
}

@Ignore({HTMLUNIT})
@JavascriptEnabled
@Test
public void testGetAttributeOfUserDefinedProperty() {
driver.get(pages.userDefinedProperty);
Expand Down

0 comments on commit e9a90c3

Please sign in to comment.