cancel
Showing results for 
Search instead for 
Did you mean: 

string not getting compare

SOLVED
Highlighted
New Contributor

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:

SanjanaZagade_0-1592973782100.png

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: string not getting compare

Hi,

 

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

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

4 REPLIES 4
Highlighted
Community Leader

Re: string not getting compare

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 😉

Un sourire et ça repart

Highlighted
New Contributor

Re: string not getting compare

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

 

Highlighted
Community Hero

Re: string not getting compare

Hi,

 

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

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Community Leader

Re: string not getting compare

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.

Un sourire et ça repart

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors