Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions javascript/atoms/test/attribute_typescript_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
assertAttributeEquals(assert, null, byId('checky'), 'never_there');
});

QUnit.test('should return null for missing class attribute', function (assert) {
assertAttributeEquals(assert, null, byId('no-class'), 'class');
QUnit.test('should return empty string for element with no class attribute', function (assert) {
assertAttributeEquals(assert, '', byId('no-class'), 'class');
});

QUnit.test('should return an empty string when attribute value is empty', function (assert) {
Expand Down
5 changes: 3 additions & 2 deletions javascript/atoms/typescript/get-attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* correct property name.
*/
const PROPERTY_ALIASES: Record<string, string> = {
'class': 'className',
'readonly': 'readOnly',
};

Expand Down Expand Up @@ -178,9 +179,9 @@
return String(getProperty(element, name));
}

const propName = PROPERTY_ALIASES[attribute] || attribute;
const propName = PROPERTY_ALIASES[name] || attribute;

if (BOOLEAN_PROPERTIES.includes(name)) {
if (BOOLEAN_PROPERTIES.indexOf(name) !== -1) {
const hasAttr = getAttribute(element, attribute) !== null;
const propValue = getProperty(element, propName);
return hasAttr || !!propValue ? 'true' : null;
Expand Down
6 changes: 6 additions & 0 deletions py/test/selenium/webdriver/common/element_attribute_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ def test_should_return_value_of_class_attribute_of_an_element(driver, pages):
assert "header" == classname


def test_should_return_empty_string_for_class_attribute_when_no_class_set(driver, pages):
pages.load("simpleTest.html")
element = driver.find_element(By.ID, "oneline")
assert "" == element.get_attribute("class")


# Disabled due to issues with Frames
# def test_should_return_value_of_class_attribute_of_an_element_after_switching_iframe(driver, pages):
# pages.load("iframes.html")
Expand Down
Loading