Search code examples
javaseleniumcucumber

Is there an easy way to get Page Objects for creating generic methods in cucumber?


i have some cucumber scenarios, and i need to create generic methods for each business area. I have some page objects, so question is how can i pass page object as parameter to Step Definition file?Is there any way instead of reflection?


Solution

  • Yes with the help of dependency injection like cucumber picocontainer, you can easily use the page objects in your step definition file.

    Please find the reference link below. As it is a tutorial, I can't share everything over here in the single comment.

    http://www.thinkcode.se/blog/2017/04/01/sharing-state-between-steps-in-cucumberjvm-using-picocontainer