If/Else NOT working properly

I created a test a couple years back where I had to scroll through a list of pop-up answers to be sure there was at least one particular answer in that pop-up list. Works fine - you set a variable as false, scroll through the list of pop-up possibilities, and if the string you’re looking for is found, change the variable to true -

I need to do something similar, but scrolling through a column of a table. I’m not sure what my target should be. I need to search the Column “Spectro Command” and find at least one instance of “CalibrateWhite” and one instance of “CalibrateBlack.”

I have been messing with this for the past two days. So I’ve found one ALMOST workaround.

First, I verify that it does NOT say “No matching records found” -

by using

verifyNotText  |  xpath=//table[@id='spectroListTable']/tbody/tr/td  |  No matching records found

If my table returns any records, it should look like this -

Now I just need to find one instance of CalibrateWhite in that field and one instance of CalibrateBlack. I am trying to make an If/Else work here -

But when I run it, it does NOT store “true” into either variable -

[info] Store ‘xpath=//table[@id=‘spectroListTable’]/tbody/tr/td[3]’ into ‘spectroCommand’

[info] Expand variable ‘${spectroCommand}’ into ‘xpath=//table[@id=‘spectroListTable’]/tbody/tr/td[3]’

[info] echo: xpath=//table[@id=‘spectroListTable’]/tbody/tr/td[3]

[info] Store ‘false’ into ‘hasWhite’

[info] Store ‘false’ into ‘hasBlack’

[info] Expand variable ‘“${spectroCommand}”.includes(“CalibrateWhite”)’ into ‘“xpath=//table[@id=‘spectroListTable’]/tbody/tr/td[3]”.includes(“CalibrateWhite”)’

[info] Expand variable ‘“${spectroCommand}”.includes(“CalibrateBlack”)’ into ‘“xpath=//table[@id=‘spectroListTable’]/tbody/tr/td[3]”.includes(“CalibrateBlack”)’

[info] Expand variable ‘${hasWhite}’ into ‘false’

[info] echo: false

[info] Expand variable ‘${hasBlack}’ into ‘false’

[info] echo: false

Someone have a way I can make this work?

1 Like

On your other question on this, you had a parameterized variable. You should do the same here.

What you want is to move through each row (tr=table row), checking the third cell ( td[3] ). So, the above quoted xpath only checks the first row–which is perfect to find your “No matching records found”.

To check each row to find your CalibrateBlack and CalibrateWhite, you will need to parameterize the table row, like you did on your other question.
xpath=//table[@id='spectroListTable']/tbody/tr[index]/td[3]

1 Like