Search code examples
squish

Identify table cells by column name


Let's say I have the following table:

|A|B|C|
|1|2|3|
|4|5|6|

To modify the value (from 2 to 7) from (row 1, column 2) I used the following line:

mouseClick(waitForObjectItem(":Dummy_JTable", "0/1"))
type(waitForObject(":Dummy_JTable"), "7")

... but if a new feature will be introduced in the SW, let's say a column D between A and B, then the upper mentioned code will put 7 in the new column D.

Is there a way to type the values somehow related to the column names/text (table header)?

Updated: I'm using Squish 5.1.3 with Python.


Solution

  • From what you are telling, I don't believe there is. What you could do is you could write a function, that reads all the table items, and returns the one you are looking for. For example:

    children = object.children(":Dummy_JTable")
    for counter in range(len(children)):
        cell_value = children[counter].text
        if cell_value == "searched cell value":
            mouseClick(waitForObjectItem(":Dummy_JTable", children[counter]))
            type(waitForObject(":Dummy_JTable"), "7")
    

    "searched cell value" = the value you expect to be in the cell.

    I also have this problem with the software I test, and because I often encounter GUI changes, I really must use this kind of functions, even tho` using cell/row is much easier.