-1

I am using a framework which is key word driven and data driven in selenium. The problem is all the methods or actions for entire application is written in one single class which has gotten very lengthy and confusing like spaghetti. I want to implements all the methods or actions page wise like a page object model but I also want it to be data driven and key word driven as well.

Any suggestions please??

@Bryan Oakley Your comment made me think harder which helped me finding the solution .

returnedStatus = runReflectionMethod("com.dmainc.ptes.test.setup.KeyWord", methodName, paramListObject);
               resultSet.add(returnedStatus);
               excelSheet.setCellData(filePath, sheetName, "Result", row + 1, returnedStatus);

So If **runReflectionMethod("com.dmainc.ptes.test.setup.KeyWord", methodName, paramListObject);**

com.dmainc.ptes.test.setup.KeyWord this part needs to be variable rather then constant which its now. so if I make it variable and I create various classes page wise which will include the respective methods/action then I can pass the required class name in this piece of code .My problem will be solved . All the methods/actions will go into their respective classes and no code bloating.

  • You say you want to implement all the methods page-wise. What's stopping you from doing that? What do you need help with? – Bryan Oakley Jun 01 '17 at 21:19
  • I am automation newbie and not very good at putting the question in a simple way but thanks for looking into it. I have updated the question with solution. – priyanka srivastava Jun 02 '17 at 16:02

1 Answers1

0

Since your framework is keyword and data-driven, it should support keyword mapping, for example Robot framework:

a dictionary mapping all library names to instances

which means that you don't need to worry too much about the refactoring of the

all the methods or actions for entire application is written in one single class

This is a classical example of a Bloater - Large Class. There are a lot of resources out there, but would recommend starting with Refactoring To Patterns and sourcemaking.

ekostadinov
  • 6,880
  • 3
  • 29
  • 47