当我们在 groovy 中定义 Web 驱动程序工厂时遇到错误消息。
我的代码中是否有任何错误?
代码片段:
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;
}
}