vendredi 16 juillet 2021

Page Object Design - when page is different depending on user

I am wondering what would be the best design for a problem I am having

I have a page in my application in which a form is displayed on the page where a user can input data. Depending on the type of user that logs in, there will be some common text boxes, dropdowns etc. and some user specific input data fields.

So for example, for an internal user all input fields will be displayed and for external users only a limited about of input fields will be displayed.

The issue is that there should be 4-5 different forms displayed depending on the user

Current i have a base page and the form page inherits the page page

public class BasePage
{
 PageFactory.InitElements(); etc.
}

Public class FormPage : Base Page
{
// All elements and methods for all types of forms
}

Here is where I am unsure what is the best approach

Should i create separate classes for each form type and inherit FormPage?

I added an example below but my application is very complex but it should give you an idea of the design

public class FormInternalUser : Form Page
{
 public void SubmitFormAction(string inputTextBox1, string inputTextBox2, string inputTextBox3, string inputTextBox4, string user)
{
// code
attachFile(user)
}

public override void attachFile(string user)
{
 //code
}
// other specific methods
}



public class FormExternalUser : Form Page
{
 public void SubmitFormAction(string inputTextBox1, string inputTextBox2, string user)
{
// code 
attachFile(user)
}
public override void attachFile(string user)
{
// code
}
// other specific methods
}

or is there a better approach? Maybe Strategy Design Pattern or something similar?

Aucun commentaire:

Enregistrer un commentaire