I am working on this teardown logic, that is to find and delete all entries created after or during test suite start time.
It is defined like:
@InheritConstructors
public class BaseListPage extends BaseCRMPage {
public static final String FilterSidebar = 'Shared repository/Zoho pages/CRM/List pages/Filter Sidebar/';
public static final String CreatedByFilterName = "Created By",
CreatedTimeFilterName = "Created Time";
private static final String TableDataXpath = "//lyte-yield[@yield-name = 'contentYield']";
public static final DateTimeFormatter DateTimeFormat = DateTimeFormatter.ofPattern("MM-dd-yyyy h:mm a");
// ...business logic and methods...
private List<TestObject> getAllCreatedAfter(LocalDateTime time) {
return DriverFactory.getWebDriver()
.findElements(By.xpath("${this.TableDataXpath}//lyte-exptable-tr"))
.stream()
.filter { WebElement rowElement ->
final LocalDateTime createdTime = getCreatedTimeFromRowElement(rowElement)
return createdTime.isAfter(time) || createdTime.equals(time);
}
.collect { WebElement rowElement -> return WebUI.convertWebElementToTestObject(rowElement) }
}
private LocalDateTime getCreatedTimeFromRowElement(WebElement rowElement) {
return LocalDateTime.parse(rowElement
.findElement(By.xpath("//*[contains(concat(' ', @class, ' '), ' newDTField ')]"))
.getText(),
this.DateTimeFormat);
}
}
When my business logic hits the method in question, getAllCreatedAfter()
, I face the following issue:
Test Cases/New Zoho/Practice Creation/Teardown FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: com.signaturemd.pages.list.PracticeListPage.getCreatedTimeFromRowElement() is applicable for argument types: (org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement) values: [[[ChromeDriver: chrome on WINDOWS (daddc317e0da7c81804544d6a48cf732)] -> xpath: //lyte-yield[@yield-name = 'contentYield']//lyte-exptable-tr]]
The topmost entry in the stack trace for this Exception…is the first line in the callback, where I am trying to hit getCreatedTimeFromRowElement()
.
Keep in mind, that I have a NewTestListener
that uses my SMDWebDriverUtils
, which is defined to be:
package com.signaturemd.utils
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import com.kms.katalon.core.webui.driver.DriverFactory
import internal.GlobalVariable
public final class SMDWebDriverUtils {
private static WebDriver driver;
public static void SetUpDriver() {
final String userHomeDirectory = System.getProperty('user.home');
System.setProperty('webdriver.chrome.driver',
"${userHomeDirectory}\\${GlobalVariable.pathToKatalon}\\configuration\\resources\\drivers\\chromedriver_win32\\chromedriver.exe");
ChromeOptions chromeProfile = new ChromeOptions();
chromeProfile.addArguments("user-data-dir=${userHomeDirectory}\\${GlobalVariable.pathToUserDataDir}");
chromeProfile.addArguments('profile-directory=Default');
this.driver = new ChromeDriver(chromeProfile);
this.driver.manage().window().maximize();
DriverFactory.changeWebDriver(this.driver);
}
public static void CloseDriver() {
if (this.driver != null)
this.driver.quit()
}
public static void DoWebAction(Closure onAction) {
this.SetUpDriver();
onAction();
this.CloseDriver();
}
}
When I attempt to debug the code, putting breakpoint on the offending line, I see that:
but, when I look into this EventFiringWebDriver
, I see it is deprecated.
The SMDWebDriverUtils
explicitly sets DriverFactory.getWebDriver()
to ChromeDriver
object.
What is causing this absurd state issue to happen, and what can I do about it?
NOTE: Using SMDWebDriverUtils.driver
to get WebDriver doesn’t work either, as it gives similar issue: