-1

I have the below function. It always says the text does not match. This is within test complete. I have put a watch on both items and both dont contain any white spaces. I am new to this but wondered if there is anything obvious I am doing wrong?

function VerifyComboBox(/*formcontrolname, value*/)
{
var formcontrolname = "CassetteTypeFilter";
var value = "Filter By Cassette Type";

 try{ 
      /*Boolean condition is declare either to execute code or not*/
    if (formcontrolname && value !== null)
    {
     /*convert String to object */ 
    var name = ConvertToObject(formcontrolname);

    object=Sys.Browser("*").Page("*").FindChildByXPath("//*[@formcontrolname='" + name + "' and contains(., '" + value + "')]");    


    /*Waits until object appears*/
    waitUntilObjectIsVisible("//*[@formcontrolname='" + name + "']");    


    /*scrolll to the invisble element*/
    object.ScrollIntoView();
    var visibleText = object.innerText.replace(/▼/g,'')


    /*Boolean conditions to check the value of the element*/
    if (visibleText == value) {
     Log.Checkpoint("Text matches");
     }
     else {
     Log.Error("Text does not match");
     }
     }
    }
 catch (e)
    {
       // Posts an exception message to the test log`enter code here`
       Log["Error"]("EXCEPTION OCCURED: " + e["description"]);
    }
}

enter image description here

3
  • 1
    What are the values for visibleText and value at the time of if (visibleText == value) {? - What does console.log(visibleText) and console.log(value) show you? Commented Apr 25, 2018 at 10:28
  • 2
    Can you produce a minimal reproducible example? Commented Apr 25, 2018 at 10:29
  • Added a picture above Commented Apr 25, 2018 at 10:59

1 Answer 1

0

TestComplete gives you aqString in order to avoid this kind of things. Use aqString.Compare in order to compare strings properly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.