简体   繁体   中英

marathonITE script to tick a checkbox in a JTable cell

I'm using marathonITE testing tool to automate testing of a java swing application.

In one of the windows i have a JTable with 6 columns and N number of rows. Two columns of that table are checkbox type columns.

My requirement is to write the automation script to tick the check box when the row and column is given.

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

I tried this line but it directs the script to

class Fixture:


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

which then stops the process.

Is there a way to tick the checkbox within a table when column and row is given?

I found a workaround for this problem. In the first part i traverse through the table and checks whether the test value is equal to each of those cell values. In the second part i use keystrokes to traverse to that particular row and column and use space and enter keystrokes to tick the check box.

Note that this method works only for checking a single check box. For multiple check boxes will have to traverse back using key strokes and re do the keystroke traversing.

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

Write your code in this way:

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

This is working for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM