on 17 Apr 2023 09:44 AM - edited on 10 Jul 2024 03:41 PM by HannahM
With help of JavaScript Event, we can extract the value of input field and add the conditional JavaScript code(if else condition) to check if its expected or default or empty value.
For example, consider that current input field is assigned with the default value "Dynatrace" then we can try use the below JS code to check the same,
var currentvalue = document.querySelector("#name").value;
var valuetobechecked = "Dynatrace";
if(currentvalue == valuetobechecked)
{
//console.log("current value matches with the expected one");
api.info("current value matches with the expected one");
}
else if(currentvalue.length>0)
{
//console.log("current value not matches with the expected one. Actual Value: " + currentvalue);
api.info("current value not matches with the expected one. Actual Value: " + currentvalue);
//add additional code if its different value.
}
else
{
//console.log("Empty value");
api.info("Empty value");
//add additional code if its empty value.
}