Answered

Referencing to LIST doesn't work with + and - operations.

Hi,

I have a list and during a loop, I'm referring to a cell in the list. The reference syntax doesn't support if I used @loop_index-1 either in row and or column. 

For example, below works if I used @row_index variable which has the value "1"

However, if I use @row_index-1, it doesn't interpret this as 0.

 

0
5 comments
Avatar
Joseph Hamdan

Hi Hasib,

Could you please provide additional information about the comparison you are making?

List columns/rows start from 0, not 1. So if you are grabbing a value from the web page where the XPath dynamically moves with your Loop starting with the number 1, your list will start with 0 and that should be taken into account, you can use separate variables for that if your XPath does find anything with 0 and always starts with 1.

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Hasib Rostaiee

Hi Jespeh,

Yes, I'm aware of it, the problem is calculations such as [@index-1] doesn't work when referencing to the list values.

For example, @index= 2 which is the the variable assigned by the loop counter. Since the list rows starts by 0 , I would use below expression to row 2:

@list_name[@index-1][1] 
@{list_name.column_name}[@index-1]

None of the above woks but if I use @list_name[@index][1] or @list_name[1][1] it works. My point is calculation inside the brackets are not working. 

 

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Hasib,

Thanks for clarifying. Compare command expects to be provided with 2 values and it can read through variable values, but it cannot perform arithmetic operations. The only command that can do that is Set_Var with Expression type. Since your Loop always starts with 1 and you want to start with 0 for the list, you can create a Set_Var step with value 0 that runs before your loop, then inside the loop before the next iteration, you can add another Set_Var step with Expression type that increases the value by 1 for the same variable, so it keeps it moving. For example, notice steps 2, 5 and 6 below:

Please let me know if this makes sense or if you have any other questions.

Regards,
Subject7 Team

0
Comment actions Permalink
Avatar
Hasib Rostaiee

Thank you, I used set_var to do the calculation and used the new variable in the compare step. Do you think it's a good enhancement to make compare steps take care of calculation?

0
Comment actions Permalink
Avatar
Joseph Hamdan

Hi Hasib,

Glad to hear it works. You are welcome to submit a feature request, but making Compare command perform calculations defeats the purpose of the command as it's built to compare between values (static or dynamic), but not perform calculations. 

Regards,
Subject7 Team

0
Comment actions Permalink

Please sign in to leave a comment.