Skip to content

Commit

Permalink
Moved value check to after validating applicable element type
Browse files Browse the repository at this point in the history
  • Loading branch information
reallymello committed Jul 7, 2024
1 parent 364c425 commit 8b03838
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/transport/selenium-webdriver/method-mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,14 +608,15 @@ module.exports = class MethodMappings {

async checkElement(webElementOrId) {
const element = await this.getWebElement(webElementOrId);
const value = await element.isSelected();
const elementType = await element.getAttribute('type');
const checkableTypes = ['checkbox', 'radio'];

if (!checkableTypes.includes(elementType)) {
throw new Error('must be an input element with type attribute \'checkbox\' or \'radio\'');
}

const value = await element.isSelected();

if (!value) {
await element.click();
}
Expand Down

0 comments on commit 8b03838

Please sign in to comment.