0

I have a enum of that has locator,classname.

public enum listofclasses{
    note(By.css(".notes", "NotesPage"),
    document(By.css".docs", DocumentsPage");
}

Public NotesPage a extends BasecustomerPage{
    public a(BasePage owningPage){
    }

    public pageisdisplayed(){
    }
}

when i Am running the test with Junit my test has to create dynamic object of the class based on string passed.

@Test
public class test(){
    for(listofclasses list : listofclasses.values ){
        String className = getclass(list);

        Class<?> cls = Class.forName(className);
        Object clsInstance = (Object) cls.newInstance();
    }

How do I get the parameterized constructor and access the methodsof the class

Monika
  • 23
  • 3
  • This might help you https://stackoverflow.com/questions/37628/what-is-reflection-and-why-is-it-useful – Magesh May 04 '18 at 16:39
  • You’ll probably want to start by reading the [documentation for Class.getConstructor](https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#getConstructor-java.lang.Class...-). To learn how to use a Constructor object, follow the appropriate links in that documentation. – VGR May 04 '18 at 17:11
  • Possible duplicate of [What's the proper way to use reflection to instantiate objects of unknown classes at runtime?](https://stackoverflow.com/questions/7698237/whats-the-proper-way-to-use-reflection-to-instantiate-objects-of-unknown-classe) – Robin Green May 04 '18 at 19:59

0 Answers0