Home » Archived » Jubula » Select table row - row has to fulfill multiple conditions
Select table row - row has to fulfill multiple conditions [message #1314255] |
Fri, 25 April 2014 04:57  |
Eclipse User |
|
|
|
Hi,
so far I could get along with selecting rows/columns by value using ub_tbl_selectValueFromColumn or ub_tbl_selectValueFromRow. However, I have a new case and I don't know how to solve it with the existing jubula mechanisms.
First of all, I want to test a RCP application. This app has tables with multiple columns. Such a table could look like this:
A B C
---------
A1 B1 C1
A2 B1 C2
A1 B2 C1
Hence, a certain value can be contained in a column multiple times. Now lets say I want to select the row which has A == A1, B == B1 and C == C1. Just searching for a row containing e.g. A1 would not be enough as multiple rows can have this value in A and I want to select a specific one. The only thing I know is that the cominbation in the table is unique, so there is no other row with A == A1, B == B1 and C == C1.
Is it possible to select a row/column which has to fulfill multiple conditions?
|
|
| |
Re: Select table row - row has to fulfill multiple conditions [message #1316694 is a reply to message #1314800] |
Sat, 26 April 2014 13:38   |
Eclipse User |
|
|
|
The solution I was thinking of doesn't work, because of the way event handlers behave. I believe it can still be done, but the solution is trickier and involves nested event handlers.
You need to define a number of test cases equal to the number of conditions plus two. The following assumes that the values you are looking for have been stored in variables A1, B1, and C1. It also assumes that you have fewer than 1000 rows in your table; you can adjust that number to whatever makes sense for your situation. Note that all of the "Check" steps must be Test Steps, and not Test Cases.
TC_Base:
1: Set ROWNUM = 1
2: Check $ROWNUM > 1000
Event Handler (Action Error): Empty Case, RETURN
Event Handler (Check Failed): TC_A, RETRY, 1000 times
TC_A:
1: Store text from Table Cell at Row $ROWNUM, column (A's column) in variable A
2: Store text from Table Cell at Row $ROWNUM, column (B's column) in variable B
3: Store text from Table Cell at Row $ROWNUM, column (C's column) in variable C
4: Check $A != $A1
5: Set ROWNUM = ?trunc(?add($ROWNUM,1),0)
Event Handler (Check Failed): TC_B, RETRY, 1 time
TC_B:
1: Check $B != $B1
2: Set A = ''
Event Handler (Check Failed): TC_C, RETRY, 1 time
TC_C:
1: Check $C != $C1
2: Set B = ''
Event Handler (Check Failed): TC_Match, RETRY, 1 time
TC_Match:
1: Select Cell in Row $ROWNUM, column (any column) in table
2: Set C = ''
3: Set ROWNUM = 1001
Please let me know if this works, or doesn't make enough sense!
[Updated on: Sat, 26 April 2014 14:15] by Moderator
|
|
|
Re: Select table row - row has to fulfill multiple conditions [message #1316810 is a reply to message #1316694] |
Sat, 26 April 2014 15:13   |
Eclipse User |
|
|
|
I just figured out another solution, along the lines of my original idea, that uses five test cases (not counting the empty event handler, which I forgot to count last time) regardless of the number of conditions, and allows you to use a dataset containing any number of column/value pairs. It is even less intuitive than the other solution, but can be extended without increasing the number of test cases or degree of nesting. All that needs to be done to increase the number of conditions is to add rows to the dataset.
TC_Multi:
1: Set NC = (number of conditions, e.g. 3 in the example you gave)
2: Set ROWNUM = 1
3: Set MATCHES = 0
4: Check $MATCHES greater or equal than $NC
Event Handler (Check Failed): TC_TestRow, RETRY, (1000 or some number higher than the number of rows) times
Event Handler (Action Error): Empty Test Case, RETURN
TC_TestRow:
1: Set MATCHES = 0
2: TC_TestCondition
3: Set ROWNUM = ?trunc(?add($ROWNUM,1),0)
TC_TestCondition (This is the one that will reference the dataset, with columns COLUMN and VALUE)
1: Store text from Table Cell at Row $ROWNUM, Column =COLUMN in variable COLVAL
2: Check $COLVAL not equals =VALUE
Event Handler (Check Failed): TC_Match, RETRY, 1 time
TC_Match:
1: Set MATCHES = ?add($MATCHES,1)
2: Set COLVAL = ''
3: Set MATCH_COPY = $MATCHES
4: Check $MATCH_COPY < $NC
Event Handler (Check Failed): TC_Select, RETRY, 1 time
TC_Select:
1: Select Table Cell at Row $ROWNUM, Column (any)
2: Set MATCH_COPY = 0
I hope this helps!
[Updated on: Sat, 26 April 2014 15:19] by Moderator
|
|
| | | | |
Goto Forum:
Current Time: Wed Jul 23 04:57:20 EDT 2025
Powered by FUDForum. Page generated in 0.24809 seconds
|