Comparing table data in IF not working
I have this weird problem were everything seems correct but TC isn't doing the correct steps.
I have a data driven loop, and I am going to check if the product number is a specific product, and it should do the steps I want.
This has worked in the past, not sure why it stopped working.
In the image below, in the blue box, the product number is filled in - this is correct.
For the sake of testing, I added the yellow box - these also give and store the correct values.
The problem is in the red box, for some unknown reason it just skips the if.
Below is a small snippet of the test log, and you can see that the log action provided the correct product number.
Also, you can see that the text in the textbox is also the correct value.
And lastly a screenshot of the if itself.
Can anybody help me notice the issue?
Thanks in advance.
Solved! Go to Solution.
In the blue section of "If Object", does the if statement also sets the text for ProductNumber or does it only set it in the else statement? The red section may fail because of this.
Should Value2 value be in quotes?
Apart from that, I can't really see anything wrong.
The "If Object" in the blue section is to check if a column for the product number without - is available.
If so, it will enter the product number without -.
But in this case that column is not available.
I am not sure if Value2 should be in quotes, I can try, I never put quotes there.
Even though the values look like they match, the If is probably failing because there's a type mismatch. @rraghvani has the right idea. You need to force both values into a string so you know for sure they are the same type. You can use the quotes or something like aqConvert
@Marsha_R I tried the quote idea but this didn't work.
I put the product number directly in the variable and the IF worked. This means that the data from the table isn't seen the same as if I put it directly in the variable.
I wanted to try the aqConvert, but I am not sure what to do in the keyword test.
Do you think aqConvert the table data to a string and put it in ProductID works? Or like I am doing now, put the table data in the variable beforehand and convert that to a string?
You can use the method like so (not a great example!),
Also, the value that's stored in your variable may contain a line feed or carriage return character and hence the if..statement is not working as you expect.
Thank you. But this is also not working for this product number..
The strange thing is, I ran another test, and here everything works fine. So that means my original code works and your aqConvert works.
Now I am very lost why it doesn't work for this product number but other tests are going fine.
I ran the test were the check works and it looks like this.
The first log is the value from the table data.
The second log is the value from the variable.
The other logs are what the check is supposed to do.
As you can see for this specific scenario, it works
I am going to run more purchase scenarios and see what the results are going to be. I still think it is strange.
The log output may not show "hidden" characters, so don't always rely on it.
I can't see anything wrong with your keyword test, so it must be the data format.