peterrexj / Selenium.Essentials

A simple framework to support automation with Selenium. Provides different control like Table, Textbox, Checkbox defined on top of IWebElement making the life of an automation engineer much easier by following the test rather than defining control operations. Provides API support to perform integration tests.
Apache License 2.0
10 stars 5 forks source link

Collection Control performance issue #32

Open 3ggerhappy opened 2 months ago

3ggerhappy commented 2 months ago

Hi,

I am getting elements from a grid/table using the CollectionControl to convert the contents to a list of custom object and experiencing some performance hit/slowness compared to just using Enumerable IWebElements.

In my case it is like 300 rows and 12 columns. Using CollectionControl it takes 3.5 minutes and just 55 seconds with plain old Driver.Findelements to Enumerable IWebElements. Not sure how CollectionControl is implemented but any way we can improve its performance?

I get all the rows first into a Collection Control then loop through the items to get the cells for each, stored again on Collection Control then looping the cells control to assign to the properties of my custom class. Same logic using IWebElement but this way its way much faster.

I have also noticed the TableControl on the new verison but not sure how to use it, can I utilizie this for my use case?

peterrexj commented 2 months ago

Hi,

I am getting elements from a grid/table using the CollectionControl to convert the contents to a list of custom object and experiencing some performance hit/slowness compared to just using Enumerable IWebElements.

In my case it is like 300 rows and 12 columns. Using CollectionControl it takes 3.5 minutes and just 55 seconds with plain old Driver.Findelements to Enumerable IWebElements. Not sure how CollectionControl is implemented but any way we can improve its performance?

I get all the rows first into a Collection Control then loop through the items to get the cells for each, stored again on Collection Control then looping the cells control to assign to the properties of my custom class. Same logic using IWebElement but this way its way much faster.

I have also noticed the TableControl on the new verison but not sure how to use it, can I utilizie this for my use case?

Hi @3ggerhappy,

Thanks for bringing up this issue. The collection and table control is introduced to deal with dynamic row positioning. I have seen test engineers hardcoding the row position and performing operations. I was thinking of removing the for loops, hardcoded values and dynamically get the row based on conditions/filters and give back position in the collection and then perform the action. When it was developed I noticed some performance issues, as behind the scenes it takes the row and columns count and does some action. 230 seconds is too much waiting and I think it should be improved. I will look into it and try to get a fix and build a doc on the best practices for using this control.

Thanks, Peter

peterrexj commented 1 month ago

Hi @3ggerhappy ,

I have made some changes and can see good improvements in the processing time on both Collection and Table control. Please install the latest version >=1.6.0

I have updated some documentation around both these controls and will expand with more details soon. https://github.com/peterrexj/Selenium.Essentials/wiki/PageObject-with-new-controls#table-control https://github.com/peterrexj/Selenium.Essentials/wiki/PageObject-with-new-controls#collectioncontrol

Let me know after you test and ok to close the issue.

3ggerhappy commented 1 month ago

Hi @peterrexj

First of all Thanks for the updates! I really appreciate the utility and efficiency your project provides with my automation.

I have tested and run as follows - 12 Columns and 437 rows, same logic as before of getting first the rows into collection control, then getting child cells/columns from the rows into another collection control. Then assign the text of the cells to my custom class properties(I just hard coded the index on the cells as per the property).

Old Version: 9.8 minutes New Version: 6.4 minutes Find Elements: 2.3 minutes

There is some improvement, but still would use the find elements > IEnumerable for this particular use case for now. We could close the issue for now(but in the future some more improvement would be good) as I think this would only happen on such big tables and performance is negligible for small tables. I am still using it in fact for other List of elements that i need just for the utilities it provides like lazy loading and the waits. Its just on these table use case w/c is slow for me.

Once again thanks for creating this wonderful tool!