0
private static <T> T GetPage()  
{
    T page = new T();
    PageFactory.initElements(BrowserFactory.getWebDriver(), page);
    return page;
}

T page = new T() ---- says Error: cannot instantiate the type T

I am completely new to this. Can you help me why I am getting this error? Below is my C# code for the same thing and it works fine. Am not able to replicate this in Java.

private static T GetPage<T>() where T : new()
{
   var page = new T();
   PageFactory.InitElements(Browser.Driver, page);
   return page;
}
hemanth
  • 37
  • 1
  • 6

0 Answers0