Search

Tip | How to handle long forms with selenium

Updated: Oct 12




The problem


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.



#topic #pageobjects #dynamiclocators #selenium #api #webDriver #testing

11 views

© 2020 Qa lemming