简体   繁体   中英

Actions class operations inside iframe(Java-Selenium)

I am Currently inside a iframe and I am trying to perform Click and Right Click Operations using Actions class. At the time of executing the script the click and Right click operations are performed on the incorrect elements(Operations are performed on the elements below the Expected Elements). The locators that I am using are correct.

How do I perform Click and Right Click operations inside a iFrame using Actions Class or do we have an alternate way

Code:- I have switched to the iframe

**Click Operation:-** 

Actions actions = new Actions(driver.get());
            actions.moveToElement(wait.get().until(ExpectedConditions.elementToBeClickable((By.xpath(currentObject)))));
            Thread.sleep(2000);
            actions.click();
            actions.build().perform();

**Right Click Operation:-** 

    Actions actions = new Actions(driver.get()); 
        actions.moveToElement(wait.get().until(ExpectedConditions.visibilityOfElementLocated(By.xpath(currentObject)))); 
        actions.contextClick(); 
        actions.build().perform();

您是否将驱动程序切换到正确的框架?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM