I am not well versed in JS at all and am getting ready to pull my hair out regarding this issue. The issue at high level: I have to grab all values from a dropdown and randomly pick one of them to enter in a dropdown field. Then I have to verify if the field value that got saved is the same as the one I entered.
Three values are possible: “True”, “False”, or “None Available”. Where “None” also gets saved as “False” after the fact. Therefore, when the field is saved, only two values are displayed: “True” or “False”.
I have the setup as following:
let dropdownVal = ["True", "False", "None Available"];
let randomVal = dropdownVal[Math.floor(Math.random() * dropdownVal.length)];
//I enter the value resulting from randomVal into the dropdown field using xpath.
let evalDropdownVal = (typeof randomVal == 'None Available') || (typeof randomVal == 'False') ? "False" : "True"
//Here I grab the xpath for the "saved" field and evaluate whether the values match.
What keeps happening is, the evalDropdownVal keeps evaluating the opposite. I.e if the value is True, it evaluates it as False and my final matching keeps failing due to that.
I apologize in advance if I butchered the format of the question or didn’t give enough information.