Advanced Control Type - Table

For the objects provided by the table in the application under test, CukeTest provides three controls:

  • Table: Table control, as the external container control of the table, is also recommended by CukeTest;
  • TableRow: Table row control, which represents a row of data in the table, can further obtain the cells in it, that is the TableCell control;
  • TableCell: Cell control, representing the smallest control unit in the table, these cells contain data, and in many cases can be double-clicked to switch to the edit state for editing.

These three different controls cooperate with each other to perfectly complete the automation for form applications.

In fact, CukeTest also provides another form control DataGrid, which differs from Table control in that: The two controls Table and DataGrid are prepared for the inconsistency in table implementation of two different frameworks: in the application of WinForm and WPF framework, the table will be recognized as DataGrid control; and in the Qt framework as Table control.

Table

The object type used to describe the table view control - Table, in most cases, because the cells in the table can provide fewer identification properties, and it is also necessary to identify the operated cells one by one before operating the cells Not an appropriate way to automate. Therefore, CukeTest includes most of the tables and the operations and attribute methods in the tables, and the automation for the tables can be done directly on the Table object. for example:

Assume that there is a cell at row 2, column 3, and you need to modify the value of the cell to targetValue. If you follow the conventional automated development process, it should be as follows:

JavaScript
Python
// After identifying the cell as `TargetCell`
await model.getTableCell('TargetCell').set(targetValue);
# After identifying the cell as `TargetCell`
model.getTableCell('TargetCell').set(targetValue)

Whereas the suggested approach is this:

JavaScript
Python
await model.getTable('Table').setCellValue(1, 2, targetValue);
model.getTable('Table').setCellValue(1, 2, targetValue)

In this way, the cell can be operated without identifying the operated cell, so that you only need to know the number of rows and columns in the table to traverse all the cells in the entire table. This is why it is recommended that you operate on Table objects rather than on cell objects.

type file definition

JavaScript
Python
export interface IWinTable extends IWinControl {
    clickCell(rowIndex: number, columnNameOrIndex: string | number): Promise<void>;
    cellValue(rowIndex: number, columnNameOrIndex: string | number): Promise<string>;
    setCellValue(rowIndex: number, columnNameOrIndex: string | number, value: string): Promise<void>;
    showHeader(nameOrIndex: string | number): Promise<IWinTableCell>;
    
    select(rowIndex: number, columnName: string | number): Promise<IWinTableCell>;
    scrollTo(rowIndex: number, columnName: string | number): Promise<IWinTableCell>;
    scrollLeft(): Promise<void>;
    scrollToTop(): Promise<void>;
    scrollToBottom(): Promise<void>;
    findItemInColumn(columnNameOrIndex: string | number, 
        valueOrListener: string | ((element) => Promise<boolean>))
        : Promise<IWinTableCell>

    columnName(index: number): Promise<string>;
    columnHeaders(): Promise<string[]>;
    columnCount(): Promise<number>;
    rowCount(): Promise<number>;
    row(rowIndex: number): Promise<IWinTableRow>;
    rowData(rowIndex: number): Promise<string[]>;
}  

export interface IWinDataGrid extends IWinTable {

}
class WinTable(WinControl):
	def clickCell(rowndex: int, columnNameOrndex: Union[str, int]) -> None
	def cellValue(rowndex: int, columnNameOrndex: Union[str, int]) -> str
	def setCellValue(rowndex: int, columnNameOrndex: Union[str, int], value: str) -> None
	def showHeader(nameOrndex: Union[str, int]) -> "WinTableCell"
	def select(rowndex: int, columnNameOrndex: Union[str, int]) -> "WinTableCell"
	def scrollTo(rowndex: int, columnNameOrndex: Union[str, int]) -> "WinTableCell"
	def scrollLeft() -> None
	def scrollToTop() -> None
	def scrollToBottom() -> None
	def findItemInColumn(columnNameOrIndex: Union[str, int], valueOrListener: str) -> "WinTableCell"
	def columnName(index: int) -> str
	def columnHeaders() -> List[str]
	def columnCount() -> int
	def rowCount() -> int
	def row(rowndex: int) -> "WinTableRow"
	def rowData(rowndex: int) -> List[str]

class WinDataGrid(WinTable):
    ...

Object Operation API Introduction

clickCell(rowIndex: number, columnNameOrIndex: string | number): Promise<void>

Click the cell at the target index position. If the target position is not already on the screen, it will be scrolled to a visible position and clicked. Click the cell at the target index position. If the target location is not already on screen, it will be scrolled to a visible position and clicked.

  • rowIndex: number, Represents the row position index of the target cell, starting from 0 to calculate the position;
  • colIndex: number, Represents the column position index of the target cell, starting from 0 to calculate the position;
  • returns: An asynchronous method that returns no value.

showHeader(nameOrIndex: string | number): Promise<IWinTableCell>

Scroll the target header (column header) to the visible position, and return the cell object at the target position. Compared with the columnHeader() method, it has more operations to scroll to the target header, and returns an object instead of a value.

  • nameOrIndex: number or string, Represents the index of the column or the name of the column, starting from 0 to calculate the position;
  • returns: Promise<TableCell>, Asynchronously returns the cell object of the header.

select(rowIndex: number, columnName: string | number): Promise<IWinTableCell>

Click the target cell and return the TableCell object of the cell. Compared with the scrollTo() method below, this method has an additional operation of actually clicking/selecting the cell.

  • rowIndex: number, Represents the row position index of the target cell, starting from 0 to calculate the position;
  • colIndex: number, Represents the column position index of the target cell, starting from 0 to calculate the position;
  • returns: Promise<TableCell>, Asynchronously returns the object of the target cell.

scrollTo(rowIndex, colIndex): Promise<TableCell>

Scroll to the target index position, and return the cell object at the target position. If the target position has not been loaded, it will be loaded until the target index position is loaded.

  • rowIndex: number, Represents the row position index of the target cell, starting from 0 to calculate the position;
  • colIndex: number, Represents the column position index of the target cell, starting from 0 to calculate the position;
  • returns: Promise<TableCell>, Asynchronously returns the object of the target cell.

scrollLeft(): Promise<void>

Scroll to the far left of the table.

  • returns: An asynchronous method that returns no value.

scrollToTop(): Promise<void>

Scroll to top of table.

  • returns: An asynchronous method that returns no value.

scrollToBottom(): Promise<void>

Scroll to bottom of table.

  • returns: An asynchronous method that returns no value.

cellValue(rowIndex, columnNameOrIndex): Promise<string>

To get the value of the target row and column cell, it can be understood as the Getter method relative to the setCellValue() method.

  • rowIndex: number, Represents the row position index of the target cell, starting from 0 to calculate the position;
  • colNameOrIndex: number or string, Represents the column position index of the target cell, starting from 0; you can also pass in the name of the target column in the header, such as "Name", 'ID'.
  • returns: Promise<string>, Asynchronously returns a result of type string, no matter what is in the target cell. If the row and column position is exceeded, or the passed column name does not exist, 1006: OutOfRange will be thrown.

setCellValue(rowIndex, columnNameOrIndex, value): Promise<void>

Edit the value of the target row and column cell, and the column position can also pass in a string. If you do this, it will search for the corresponding column position in the header.

  • rowIndex: number, Represents the row position index of the target cell, starting from 0 to calculate the position;
  • colNameOrIndex: number or string, Represents the column position index of the target cell, starting from 0; you can also pass in the name of the target column in the header, such as "Name", 'ID'.
  • value: string or number, The desired cell value.
  • returns: An asynchronous method that returns no value. If the row and column position is exceeded, or the passed column name does not exist, 1006: OutOfRange will be thrown.

findItemInColumn(columnNameOrIndex: string | number, valueOrListener: string | callback(value): Promise<IWinTableCell>

Search for eligible cells in the target column. You can search based on the cell name, or you can use the test function callback to complete a more complex search.

  • columnNameOrIndex: string or number. Represents the name or index of the target column.
  • valueOrListener: string or function. If the input is a string, it will automatically search for cells with the same value as the string. If it is a function, it will pass the value of the current list item into the function for testing:
    • callback: Test function, used to test the content of the input.
      • value: The input parameter, sring type, when called in the form, will automatically pass the value of the current cell to the callback function.
      • returns: The result of running the test function, boollean, When the return value is false, the next test will continue; otherwise the callback will complete and exit.

columnName(index: number): Promise<string>

Get the value of the target table header (column header).

  • index: number, Represents the index of the column, starting from 0 to calculate the position;
  • returns: Promise<string>, Asynchronously returns the name of the header.

columnHeaders(): Promise<string[]>

Get the content of the table header and return it as a string array.

  • returns: Promise<string[]>, Asynchronously returns an array of type string, regardless of what is in the header.

columnCount(): Promise<number>

Get the count of all headers. The value is equal to the length of the array returned by columnCount().

  • returns: Promise<number>, Asynchronously returns the number of headers.

rowCount(): Promise<number>

Get the number of rows in the entire table, it will automatically scroll to the bottom of the table to load all the data.

  • returns: Promise<number>, Asynchronously returns the row count of the table.

row(rowIndex: number): Promise<IWinTableRow>

Get the object of the target row, and return the TableRow object of the target row.

  • returns: Promise<TableRow>, The object of the asynchronous target row.

rowData(rowIndex: number): Promise<string[]>

Get all the content in a row of the table and return it as a string array.

  • index: number, Represents the index of the row, starting from 0 to calculate the position.
  • returns: Promise<string[]>, Asynchronously returns an array of type string, regardless of what is in the header.

TableRow

The control used to describe the rows in the table is usually identified by or returned by the row() method of the Table object. Since it provides the method next() for obtaining the front and rear table row objects similar to doubly linked list andprevious()`, can play a very good effect when traversing data (such as traversing to get each row of data).

type file

JavaScript
Python
export interface IWinTableRow {
    next(): Promise<IWinTableRow>;
    previous(): Promise<IWinTableRow>;
    cell(index: number): Promise<IWinTableCell>;
    rowData(): Promise<string[]>;
}
class WinTableRow(WinControl):
	def cell(index: int) -> "WinTableCell"
	def rowData() -> List[str]
	def scrollntoView() -> None

Object Operation API Introduction

next(): Promise<IWinTableRow>

Get the adjacent next row control, which is the TableRow object of the next row.

  • returns: Promise<TablRow>, Asynchronously returns the TableRow object for the next row.

previous(): Promise<IWinTableRow>

Get the adjacent previous row control, that is, the TableRow object of the previous row. It is just the opposite of the next() method.

  • returns: Promise<TablRow>, Asynchronously returns the TableRow object of the previous row.

cell(index: number): Promise<IWinTableCell>

Get the cell at the specified index in the current row. Just like the Table object has the row method to get the row object, the TableRow object also has the cell method to get the cell object.

  • index: number, Represents the index of the cell, starting from 0 to calculate the position;
  • returns: Promise<TableCell>, Asynchronously returns the cell object.

rowData(): Promise<string[]>

Get all the data of the current row and return it as a string array.

  • returns: Promise<string>, Asynchronously returns all data in the row.

TableCell

Definitions and methods for cell controls.

type file definition

JavaScript
Python
export interface IWinTableCell {
    value(): Promise<string>;
    select(): Promise<void>;
    set(value: string): Promise<void>;
    row(): Promise<IWinTableRow>;
    scrollIntoView(): Promise<void>;
}
class WinTableCell(WinControl):
	def value() -> str
	def select() -> None
	def set(value: str) -> None
	def row() -> Union[WinTableRow, WinTreeItem]
	def scrollntoView() -> None

Object manipulation API

The following are the object methods of the TableCell control.

select(): Promise<void>

Select the target cell. And the target cell will be scrolled into the visible area.

  • returns: An asynchronous method that returns no value.

set(value): Promise<void>

Modify the value of the cell directly.

  • value: string, expected cell value.
  • returns: An asynchronous method that returns no value.

value(): Promise<string>

Get the value of the cell.

  • returns: string, the value in the target cell.

row(): Promise<TableRow>

Get the object of the row where the target cell is located, that is, its parent object, and return the TableRow object of the row.

  • returns: Promise<TableRow>, The object of the asynchronous target row.

scrollIntoView(): Promise<void>

Scroll to the target cell position.

  • returns: An asynchronous method that returns no value.

results matching ""

    No results matching ""