In Groovy keyword file how to use driverfactory.getWebDriver()

Hi All,

In Groovy keyword file (Ex::abc.groovy) I would like to use DriverFactory.getWebDriver() and the code is given below.

public class BaseClass
{

System.setProperty("webdriver.chrome.driver","D:\\Drivers\\chromedriver.exe")

}

public class BaseClass
{
    WebDriver driver = DriverFactory.getWebDriver()
    // do anything with driver instance
}

@Marek_Melocik

Facing error message when we defined the web driver factory in groovy. Can you please suggest me below error.

Code Snippet:
private static WebDriver driver=null;
@Keyword
public static void Customized_Start_Time()
{
driver = DriverFactory.getWebDriver();
Date date = new Date();
Date yesterday = date.previous()
SimpleDateFormat customDate;
customDate = new SimpleDateFormat(“d MMM yy”); // Date format could be 03-Sep-20
String dateOutput = customDate.format(yesterday);
System.out.println(dateOutput);

	//Date Format is 03-Sep-20
	String[] dateParts=dateOutput.split(" ")
	String res=dateParts[0]
	println dateParts[0]
	
	String beforeXpath="//table[@uitestid='gwt-debug-customFromDatePicker']/tbody/tr[2]/td/table[@class='datePickerDays']/tbody/tr[";
	String AfterXpath="]/td[";
	String LastXpath="]/div"
	boolean flag=false;
	for(int rowNum=2; rowNum<=7;rowNum++)
	{
		for(int colNum=2;colNum<=7;colNum++)
		{
			String dateval=driver.findElement(By.xpath("beforeXpath+rowNum+AfterXpath+colNum+LastXpath")).getText()
			//String dateval =WebUI.getText(findTestObject('beforeXpath+rowNum+AfterXpath+colNum+LastXpath'), FailureHandling.OPTIONAL)
			println (dateval)
			if (dateval.equals(res))
			{
				driver.findElement(By.xpath("beforeXpath+rowNum+AfterXpath+colNum+LastXpath")).click()
				flag=true;
				break;
			}
		}
		if(flag)
		{
			break;
		}
	}


}

}