1

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

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

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

select('table', 'true', '[row=1][column=0]')

我尝试了这一行,但它将脚本定向到

class Fixture:


def teardown(self):
    '''Marathon executes this method at the end of test script.'''
    pass

然后停止该过程。

当给出列和行时,有没有办法在表格中勾选复选框?

4

2 回答 2

0

以这种方式编写代码:

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

这对我有用。

于 2017-04-13T07:16:43.230 回答
0

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

请注意,此方法仅适用于选中单个复选框。对于多个复选框,将不得不使用击键回溯并重新进行击键遍历。

#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')
于 2015-09-02T05:51:47.873 回答