View Full Version : Automatic tests for grid, field names problem
elector
Sep 23, 2023, 8:20 PM
The fields in the grid have dynamic names like #ext-gen1583. I would like to add some automatic tests and for this, I need to have fixed names for fields in the grid.
Is this possible and how to do it, if it is?
I have tried to add an ID("Amount") for example to the X.Column() definition but this is not visible when the grid is rendered.
fabricio.murta
Sep 25, 2023, 2:26 PM
Hello, @elector!
You can't really give IDs to grid row cells as they are likely dynamically rendered on screen. That's particularly true if the grid has more results than what the screen can show without a scrollbar. If you rely on what's rendered on the page, rows will be missed, and potentially have different DOM rendered rows as the grid is scrolled up and down.
For smaller grids with very few records this could be safe. To ensure a consistent DOM, it is possible to disable dynamic row rendering (buffered rendering) of the grid's store with BufferedRenderer="false". This will make all grid rows to be rendered at once when the page is loaded.
Then to get a row's DOM based on this simple grid panel example (https://examples5.ext.net/#/GridPanel/ArrayGrid/Simple/): App.GridPanel1.getView().getRow(num), from 0 to the number of records (less one, it's a zero-based index array); or from 0 until it returns null.
Likewise, it would be possible to get the whole DOM table, representing the view, using CSS/javascript selection if relying in Ext.NET's client side code (Ext JS) isn't desired. Then walking through the rows <tr> and cells <td>.
Specifying an ID to every grid's cell is not supported as it potentially breaks many other features of the grid. If you need to validate the data, getting the records via App.GridPanel1.getStore().getAt(index) should be the way to go. Disabling BufferedRenderer could potentially make the cell IDs static, as long as there's nothing else "dynamic" across the page that might increment the global component count.
Hope this helps!
elector
Sep 27, 2023, 12:58 PM
Thank you very much Fabrizio
I was thinking of using Playwright for testing UI but that will not be possible then.
Do you have maybe some examples of how the EXT.NET components are tested? A practical example I could follow?
I am using MVC for my project
Thank you
Powered by vBulletin® Version 4.2.3 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.