Python 在JTable单元格中勾选复选框的marathonITE脚本

Python 在JTable单元格中勾选复选框的marathonITE脚本,python,swing,checkbox,jtable,marathontesting,Python,Swing,Checkbox,Jtable,Marathontesting,我正在使用marathonITE测试工具来自动测试JavaSwing应用程序 在其中一个窗口中,我有一个JTable,有6列和N行。 该表的两列是复选框类型的列 我的要求是编写自动化脚本,在给出行和列时勾选复选框 select('table', 'true', '[row=1][column=0]') 我试过这句话,但它将脚本指向 class Fixture: def teardown(self): '''Marathon executes this method at the e

我正在使用marathonITE测试工具来自动测试JavaSwing应用程序

在其中一个窗口中,我有一个JTable,有6列和N行。 该表的两列是复选框类型的列

我的要求是编写自动化脚本,在给出行和列时勾选复选框

select('table', 'true', '[row=1][column=0]')
我试过这句话,但它将脚本指向

class Fixture:


def teardown(self):
    '''Marathon executes this method at the end of test script.'''
    pass
然后停止这个过程


当给出列和行时,是否有方法勾选表中的复选框

我找到了解决这个问题的方法。 在第一部分中,我遍历表格并检查测试值是否等于每个单元格值。 在第二部分中,我使用击键遍历到特定的行和列,并使用空格和输入击键勾选复选框

请注意,此方法仅适用于选中单个复选框。对于多个复选框,必须使用击键向后遍历,然后重新执行击键遍历

#1st Part

            textValue = "Test Value"
            deplTable = get_component('table')
            no_of_columns = deplTable.getColumnCount()
            no_of_rows = deplTable.getRowCount()

            for col in range (no_of_columns):
                if ( col == 1 or col == 4 ):
                    for row in range (no_of_rows):

                        if ( deplTable.getValueAt( row ,col) == textValue ):
                            print 'Found at row:',row,' col:',col
#2nd Part
                            for x in range (row+1) :
                                keystroke('table', 'Down')
                            keystroke('table', 'Left')
                            if ( col > 1 ):
                                for  y in range (col-1) :
                                    keystroke('table', 'Right')

                            keystroke('table', 'Space')
                            keystroke('table', 'Enter')

我找到了解决这个问题的方法。 在第一部分中,我遍历表格并检查测试值是否等于每个单元格值。 在第二部分中,我使用击键遍历到特定的行和列,并使用空格和输入击键勾选复选框

请注意,此方法仅适用于选中单个复选框。对于多个复选框,必须使用击键向后遍历,然后重新执行击键遍历

#1st Part

            textValue = "Test Value"
            deplTable = get_component('table')
            no_of_columns = deplTable.getColumnCount()
            no_of_rows = deplTable.getRowCount()

            for col in range (no_of_columns):
                if ( col == 1 or col == 4 ):
                    for row in range (no_of_rows):

                        if ( deplTable.getValueAt( row ,col) == textValue ):
                            print 'Found at row:',row,' col:',col
#2nd Part
                            for x in range (row+1) :
                                keystroke('table', 'Down')
                            keystroke('table', 'Left')
                            if ( col > 1 ):
                                for  y in range (col-1) :
                                    keystroke('table', 'Right')

                            keystroke('table', 'Space')
                            keystroke('table', 'Enter')

用以下方式编写代码:

select('table', 'true', '{1,0}')

这对我有用。

用以下方式编写代码:

select('table', 'true', '{1,0}')

这对我来说很有用。

我从未使用过该工具,但我猜“选择”用于在表格上显示单元格焦点(即带边框的单元格)。我怀疑你真正想做的是“编辑”单元格。所以问题是如何更改表中任何单元格的数据?我猜您只是将该单元格的数据设置为Boolean.TRUE。我从未使用过该工具,但我猜“select”用于在表上显示单元格焦点(即带边框的单元格)。我怀疑你真正想做的是“编辑”单元格。所以问题是如何更改表中任何单元格的数据?我猜你只是将该单元格的数据设置为Boolean.TRUE。