In regards to the actual tests, I am trying to conditionally run a certain command. If element is present, then execute this. Using a JS If statement, nightwatch throws an error if the element is not present, as well as if I use the .isVisible command with a callback.
function iterateAndClick(elements) {
elements.value.forEach(function(element) {
browser.elementIdClick(element.ELEMENT)
})
};
if (browser.assert.elementPresent('select')) {
browser.elements('css selector', 'select.form-control > option:nth-of-type(2)', iterateAndClick)
}
or
.isVisible('#comment-textarea', function(result) {
browser.setValue('textarea[id=comment-textarea]', 'OL TEST 1234')
});
Is there a way to check if the element is present and, if it is, execute the command, and if it isn't, to graze over it and continue on without throwing an error?