Programmatically check an ag-grid checkbox

Jerry Lupo

I'm using browser automation software to run automated UI tests. Our front end site uses Vue and ag-grid. My browser automation software essentially allows us to use typical javascript/jquery selectors to interact w/ the UI automatically.

I'm trying to get our browser automation software to check boxes in an ag-grid checkbox, inside an ag-grid.

enter image description here

I am not a Vue developer, so I was trying the typical things I'd do. Things like:

$('.ag-selection-checkbox').click();

But nothing I do actually clicks and selects to box. Any advice would be greatly appreciated.

UPDATE For those in my situation. I used the ag API like so:

document.querySelector('#myGrid').__vue__
   .gridOptions.api.forEachNode((row,index) => {
       document.querySelector('#myGrid').__vue__.
           gridOptions.api.getRowNode(row.id).selectThisNode(true); 
       }
)
Shuheb Ahmed

Try using the class that is directly associated with the checkbox, in this case it would be the class applied to the input element: ag-input-field-input ag-checkbox-input.

You can get the checkbox of the first row like this:

const checkbox = document.querySelector('.ag-center-cols-viewport .ag-row .ag-checkbox-input');
checkbox.click();

Please see this example showcasing a row selection via the DOM based on the button click.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Uncheck and check checkbox of some of columns in columnsMenuTab(list of columns) in ag-Grid

AG-GRID-ANGULAR - How to check/uncheck checkbox in header component if all checkboxes in the cell renderers are checked/unchecked?

Ag grid to check if column is visible or not

ag-Grid : enter edit mode programmatically

Select ag-grid row programmatically on load

Programmatically trigger button click event on AG grid

Remove checkbox from rows in ag-grid

group selection & checkbox in ag-Grid

disable checkbox selection in Ag-grid

Ag Grid Call a function on click of checkbox

ag-grid checkbox column checked by renderer

ag-grid header checkbox selection event

AG Grid: center checkbox alone in cell

Programmatically check a custom treeview checkbox

Master Check Box in AG Grid on any column

AG-GRID unable to add icon button into each row of the ag-grid and multiselection checkbox in my ag-grid

Ag-Grid QuickFilter changing programmatically searched columns

How can I programmatically select multiple rows in ag-Grid?

Programmatically select a row ag-grid + angular 2

How to use a checkbox for a boolean data with ag-grid

ag-grid hide checkbox in some rows depend on the cell value

How to align the checkbox and text in cell to center in ag grid angular

Make ag-grid row selectable without a checkbox

How to change boolean data with checkbox in ag-grid?

getting checkbox value from ag-grid column

Angular ag-grid cell renderer checkbox not refresh value

Ag-grid checkbox render based on column data?

Ag-Grid enable checkbox selection for a single rowNode

how to apply selectAll and deSelectAll to the header checkbox in ag-grid react