Skip to content

Commit

Permalink
Fix getting Get Element States after 19.2 release
Browse files Browse the repository at this point in the history
Fixes #4037
  • Loading branch information
aaltat committed Jan 30, 2025
1 parent 05e7b22 commit afb76ab
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion atest/test/02_Content_Keywords/basic_getters.robot
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Get Element States
Wait For Elements State h1
${state} = Get Element States h1
Sort List ${state}
${expected} = Create List attached defocused enabled readonly visible
${expected} = Create List attached defocused enabled visible
FOR ${state} ${exp} IN ZIP ${state} ${expected}
Should Be Equal ${state} ${exp}
END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ Get Element Count Custom Error
Get Element States And Check Error Message Equal
Wait For Elements State h1
Run Keyword And Expect Error
... EQUALS:Elements states '['attached', 'defocused', 'enabled', 'readonly', 'visible']' (list) should be '['attached', 'enabled', 'readonly', 'visible']' (list)
... EQUALS:Elements states '['attached', 'defocused', 'enabled', 'visible']' (list) should be '['attached', 'enabled', 'readonly', 'visible']' (list)
... Get Element States
... h1
... id=heading1
... ==
... visible
... attached
Expand All @@ -269,7 +269,7 @@ Get Element States And Check Error Message Equal
Get Element States And Check Error Message Contains
Wait For Elements State h1
Run Keyword And Expect Error
... EQUALS:Elements states '['attached', 'defocused', 'enabled', 'readonly', 'visible']' (list) should contain '['detached', 'enabled', 'readonly', 'visible']' (list)
... EQUALS:Elements states '['attached', 'defocused', 'enabled', 'visible']' (list) should contain '['detached', 'enabled', 'readonly', 'visible']' (list)
... Get Element States
... h1
... *=
Expand All @@ -293,7 +293,7 @@ Get Element States And Check Custom Error
Get Element States And Check Custom Error With Values
Wait For Elements State h1
Run Keyword And Expect Error
... EQUALS:Oh NOO! <h1> should contain ['selected'] but the states where ['attached', 'defocused', 'enabled', 'readonly', 'visible']
... EQUALS:Oh NOO! <h1> should contain ['selected'] but the states where ['attached', 'defocused', 'enabled', 'visible']
... Get Element States
... h1
... *=
Expand Down
2 changes: 1 addition & 1 deletion node/dynamic-test-app/src/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default function Site() {
};
return (
<>
<h1>Login Page</h1>
<h1 id="heading1">Login Page</h1>
<p>Please input your user name and password and click the login button.</p>
<form name="login_form" onSubmit={handleSubmit}>
<table>
Expand Down
20 changes: 17 additions & 3 deletions node/playwright-wrapper/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,25 @@ export async function getElementStates(
states = stateEnum.attached;
states += (await locator.isVisible()) ? stateEnum.visible : stateEnum.hidden;
states += (await locator.isEnabled()) ? stateEnum.enabled : stateEnum.disabled;
const disabled = await locator.getAttribute('disabled');
try {
states += (await locator.isEditable()) ? stateEnum.editable : stateEnum.readonly;
const editable = await locator.isEditable();
if (editable && disabled === null) {
logger.info(`Element ${selector} is editable: ${editable}`);
states += stateEnum.editable;
} else if (!editable && disabled !== null) {
logger.info(`Element ${selector} is disabled: ${disabled}`);
states += stateEnum.readonly;
} else {
logger.info(`Element ${selector} is readonly: ${!editable}`);
states += stateEnum.readonly;
}
} catch (error) {
logger.info(`Element is not editable: ${error}`);
states += stateEnum.readonly;
logger.info(`Element ${selector} is not editable: ${error}`);
if (disabled !== null) {
logger.info(`Element ${selector} is disabled: ${disabled} and therefore readonly`);
states += stateEnum.readonly;
}
}
logger.info('Checking checked state');
states += await getCheckedState(locator);
Expand Down

0 comments on commit afb76ab

Please sign in to comment.