Currently, I am utilizing Selenium to automate the user interface using Java.
Within the UI, there is an action button that, when hovered over by the User, displays two clickable options - Create and Edit.
For ease of use, I have stored CSS locators as Enums for the Action button, as well as for the Create and Edit clickable links under the names ACTIONBUTTON, CREATEACTION, and EDITACTION respectively.
Initially, I attempted to implement the functionality with the following Java code snippet, but encountered an error stating java.lang.ClassCastException: org.openqa.selenium.By$ByCssSelector cannot be cast to org.openqa.selenium.WebElement
Actions actions = new Actions(driver);
actions.moveToElement((WebElement) DCSAdminEnums.ACTIONBUTTON.getLocator());
actions.moveToElement((WebElement) DCSAdminEnums.CREATEACTION.getLocator());
actions.click();
actions.perform();
I am seeking advice on a more optimal way to handle this scenario using the existing Enums.
UPDATE: I also tested an alternative approach with the code below, however, it unfortunately did not yield the desired outcome:
WebElement menu = driver.findElement((By.xpath("//*[@id='button-1177-btnInnerEl']")));
WebElement submenu = driver.findElement((By.cssSelector("a[id='menuitem-1175-itemEl']")));
Actions action = new Actions(driver);
action.moveToElement(menu).perform();
Thread.sleep(2000);
action.click(submenu).perform();