Skip to content

Commit

Permalink
add missing outofbounds check
Browse files Browse the repository at this point in the history
  • Loading branch information
dikwickley committed Jun 5, 2024
1 parent 1a8b44f commit b0aacb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core/asynctree.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class AsyncTree extends EventEmitter{

const nextSibbling = node.nextSibbling;

if (node.name === 'find' && nextSibbling.name === 'isElementPresent') {
if (node.name === 'find' && nextSibbling && nextSibbling.name === 'isElementPresent') {
// In case of isPresent command, we want to supress the Timeout error.
node.__args.push(true);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/core/treenode.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class TreeNode {

get nextSibbling() {
const currentNodeIndex = this.parent.childNodes.indexOf(this);
if (currentNodeIndex + 1 >= this.parent.childNodes.length){
return null;
}

return this.parent.childNodes[currentNodeIndex + 1];
}
Expand Down

0 comments on commit b0aacb8

Please sign in to comment.