Forum Discussion

Louis's avatar
Louis
Contributor
14 years ago

Non integer recognition

I'm running a script that is data driven and checks several on screen cell values against the driving data. For one cell testcomplete refuses to match the on screen value against the driving data and returns an error stating

Onscreen value "15.2 does no equal the baseline value "15.2"

It does this for any integer but only for that cell. I have checked that my checkpoints are formulated identically and that the excel  driving data is formatted consistently.

I have used the aqtrim command to remove any blank spaces for all calls checked. I can't use the "contains" command for my checkpoints as I need an excat match so am using equals.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Your baseline appears to be coming in as a string and it is being compared to an integer/real value.  



    I'd suggest doing some explicit conversion of your baseline using one of the aqConvert methods before doing the comparison or within your comparison code.
  • Hmm how would I apply that? below is the code expression I already have within my checkpoint, (I use keyword scripting but figured this bit of coding out for myself!)



    aqString.Trim(Aliases.iexplore1_new.Page.SampleDetails.Panel(2).Panel(0).Panel(0).Panel(0).Panel(21).Panel(0).Panel(80).innerText, aqString.stAll)
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Try this, instead of the trim



    aqConvert.VarToInt(Aliases.iexplore1_new.Page.SampleDetails.Panel(2).Panel(0).Panel(0).Panel(0).Panel(21).Panel(0).Panel(80).innerText)




    However, I would recommend actually you do something more on the lines of 



    if (!(aqConvert.VarToStr(baselinevalue) == aqString.Trim(Aliases.iexplore1_new.Page.SampleDetails.Panel(2).Panel(0).Panel(0).Panel(0).Panel(21).Panel(0).Panel(80).innerText, aqString.stAll))




    As mentioned above, I think the problem you're having is related to the fact that the innerText value is a string but it's possible that your baseline value is actually numeric and so the conversion of one to the other is not playing nice.  A more explicit conversion might work better. 
  • it seems it doesn't want to play and is still saying 15.2 does not equal 15.2.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Your original post had some double quotes around the second value.  Is that how it shows up in your log file?



    If that's the case, then I think it's still a matter of finding the right combination of conversions and such to compare string to string or number to number...
  • I checked out all the possible variations for aqconvert e.g strToInt, FloatToStr etc.

    I still get the problem no matter which I use.

    Strange it only does this with the one cell on screen.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I wonder if there's a non-printing character in the innerText...  If there is, then the Trim would still not work as it would not be empty space.



    Did you say you tried aqString.Contains?  If not, I would suggest looking for your baseline within the innertext.  Something like



    aqString.Contains(Aliases.iexplore1_new.Page.SampleDetails.Panel(2).Panel(0).Panel(0).Panel(0).Panel(21).Panel(0).Panel(80).innerText, baseline.value, 0, false)




    To examine that innerText to see if there's non-printing characters, try copy/paste the contents of the property as viewed in ObjectSpy (right-click, select copy) into something like MS Word and see if that shows up anything interesting.