Skip to content

Commit 13ad9d2

Browse files
committed
add missing js enabled check
1 parent a7d7311 commit 13ad9d2

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,13 @@ public String getAttribute(final String name) {
382382
return "";
383383
}
384384

385-
final HtmlUnitScriptable scriptable = element_.getScriptableObject();
386-
if (scriptable != null) {
387-
final Object slotVal = ScriptableObject.getProperty(scriptable, name);
388-
if (slotVal instanceof String) {
389-
return (String) slotVal;
385+
if (driver_.isJavascriptEnabled()) {
386+
final HtmlUnitScriptable scriptable = element_.getScriptableObject();
387+
if (scriptable != null) {
388+
final Object slotVal = ScriptableObject.getProperty(scriptable, name);
389+
if (slotVal instanceof String) {
390+
return (String) slotVal;
391+
}
390392
}
391393
}
392394

@@ -630,10 +632,16 @@ protected void assertElementNotStale() {
630632
public String getCssValue(final String propertyName) {
631633
assertElementNotStale();
632634

633-
final HTMLElement elem = element_.getScriptableObject();
635+
// TODO switch to the js free version
636+
//
637+
// final ComputedCssStyleDeclaration cssStyle =
638+
// element_.getPage().getEnclosingWindow().getComputedStyle(element_, null);
639+
//
640+
// final Definition definition = StyleAttributes.getDefinition(propertyName, driver_.getBrowserVersion());
641+
// final String style = cssStyle.getStyleAttribute(definition, true);
634642

643+
final HTMLElement elem = element_.getScriptableObject();
635644
final String style = elem.getWindow().getComputedStyle(elem, null).getPropertyValue(propertyName);
636-
637645
return getColor(style);
638646
}
639647

0 commit comments

Comments
 (0)