How to select and click multi level drop down in selenium without Select class

Viewed 59

Drop Down Buttons I want to click on "Entire Order(Same Local Site)". After clicking on OPTIONS, menu gets displayed and after hoavering over "Copy Order" sub-menu gets displayed.

public void moveToTask(WebElement ele1)
    {
        Actions ac = new Actions(driver);
        log.info("Task Link is: "+ele1);
        ac.moveToElement(ele1);
        log.info("Moved to Element by action using class");
    }

public void MoveToTaskandClick(WebElement ele)
    {
        Actions ac = new Actions(driver);
        ac.moveToElement(ele).perform();
        ac.click().build().perform();
        log.info("Move to task and clicked on"+ele);        
    }

public void copyOrder() throws InterruptedException
    {

        OPTIONS.click();
        Thread.sleep(3000);
        dropdownhelper.moveToTask(CopyOrder);
        Thread.sleep(5000);
        dropdownhelper.MoveToTaskandClick(SameSite);
        Thread.sleep(5000);
        alerthelper.acceptAlertIfPresent();
    }

It neither throws error nor it clicks on same site. It clicks only on OPTIONS and then nothing happens.

XPath I am using:

@FindBy(xpath = "//img[@name='order_options_btn']")
public WebElement OPTIONS;

@FindBy(xpath="//div[@id='copy_menu']")
public WebElement CopyOrder;

@FindBy(xpath="//div[@id='copy_menu']/table/tbody/tr[4]/td[2]/nobr")
public WebElement SameSite;

XML Code

1 Answers

Try to use this approach:

OPTIONS.click();
Actions action = new Actions(driver);
action.moveToElement(CopyOrder).perform(); // element you want to hover
driver.(EntireOrder).click();
Related