Forum Discussion

SanjanaZagade's avatar
SanjanaZagade
Occasional Contributor
5 years ago

string not getting compare

function ApplyFirmware()
{
NameMapping.Sys.browser.pagePlus1Connect2.panelRoot.panel.panel.link.panel.Click();
NameMapping.Sys.browser.pagePlus1Connect6.link.button.Click();
let currentfirmware = NameMapping.Sys.browser.pagePlus1Connect2.panelRoot.textnode4.contentText;
Log.Message(currentfirmware);
Log.Message(Project.Variables.RC1);
Delay(2000);
if(currentfirmware == Project.Variables.RC1)
{
Log.Message(currentfirmware);
}
else
{
Log.Message("fsfgsd");
}
}

 

 

output is:

variables are not getting compared but if you look into the output screenshot both variables contains the same string but still its not getting into if loop.

Can you please help me with it.

  • Hi,

     

    Try to check the length of both variables to ensure that none of them contains trailing spaces, carriage returns, etc.

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Try to check the length of both variables to ensure that none of them contains trailing spaces, carriage returns, etc.

     

    • BenoitB's avatar
      BenoitB
      Community Hero

      Sometimes some invisible characters exists as well as unicode encoding or even html tags, if the version is read from web page, i suspect hidden html hidden .. So as AlexKaras  checking the length will give a clue if it's a plain old string or hidden characters.

  • BenoitB's avatar
    BenoitB
    Community Hero

    Perhaps because you need to get the variable value with Project.Variables.VariableByName(name)) ?

     

    Sometimes a plain old global variable object in top of project is enough avoiding use of nice-functiunnalities-but-not-needed syndrom 😉

    • SanjanaZagade's avatar
      SanjanaZagade
      Occasional Contributor

      Project.Variables.VariableByName(name))  is also not working.