Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create elementHasAttribute.js #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions mabl snippets/elementHasAttribute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* JS snippet to get number of child elements
* @param {object} - mablInputs Object containing input
* variables (mablInputs.variables.user)
* @param {function} callback - The callback function
*/

function mablJavaScriptStep(mablInputs, callback) {

// Gets the page element by ID
let id_result = document.getElementById("REPLACE_WITH_ID");

// check that the element is not null or undefined
if (!id_result) {
throw Error('Element cannot be found');
}

//checks if element has attribute
let att_TF = id_result.hasAttribute("REPLACE_WITH_ATTRIBUTE");

if (!att_TF) {
throw Error('Attribute cannot be found');
}

//attribute has been found
callback(att_TF)
}