<script src="https://gist.github.com/lemmingqa/4e0c20b3702e82b694b039e43f6a10f1.js"></script><script src="https://gist.github.com/lemmingqa/e4b0762a1a474b03834d9edc05f2a139.js"></script>
I had to automate one application with forms in which we have more than 1000 elements! Yes, it is a Thousand! 100 dropdowns, 200 radio buttons, 300 text boxes, etc.
All the elements in the forms would not have unique id/names. Definitely I can not create a page object with FindBy for 1000 elements and corresponding methods for filling out the form. I also can not spend too much time on automating the forms. I was looking for some approach that would save me a lot of time.
How this can be done dynamically for selenium?
In our scriptless framework approach, we would be creating a page object in CSV format. We would be maintaining a separate CSV for each and every form/page. The Page object would have the logic to handle the dynamic locators and construct the correct info.
CSV selenium page object
This is the base for a page object that can handle a large number of locators and data without having to declare one by one. Quite simple no? But we need an extra step, how to handle this data.
Dynamically input form elements with selenium
The helper method created for puppeteer is this one, that can store duplicated requests and console errors in a file.
Final notes about selenium dynamic csv page objects
This method saved us a lot of time dealing with long forms, saving the time of declaring and maintaining about 1k locators and dealing with multiple options.