Skip to content
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)
}