【问题标题】:marathonITE script to tick a checkbox in a JTable cell用于勾选 JTable 单元格中的复选框的 marathonITE 脚本
【发布时间】:2015-11-26 21:12:32
【问题描述】:

我正在使用 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

然后停止该过程。

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

【问题讨论】:

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

标签: python swing checkbox jtable marathontesting


【解决方案1】:

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

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

#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')

【讨论】:

    【解决方案2】:

    以这种方式编写您的代码:

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

    这对我有用。

    【讨论】:

      猜你喜欢
      • 2011-08-13
      • 2012-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多