简体   繁体   English

iframe 内的 Actions 类操作(Java-Selenium)

[英]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.我目前在 iframe 中,我正在尝试使用 Actions 类执行单击和右键单击操作。 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如何使用 Actions 类在 iFrame 内执行单击和右键单击操作,或者我们是否有另一种方法

Code:- I have switched to the iframe代码:- 我已切换到 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();

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java-Selenium:TakesScreenshot大小问题 - Java-Selenium : TakesScreenshot size issue 找不到Java-Selenium WebElement错误 - Java-Selenium WebElement is not found error Java-硒允许弹出窗口 - Java-Selenium Allow Popup Window 无法在 Java-Selenium 中找到元素错误 - Unable to locate element error in Java-Selenium 使用 Python-Selenium 启动 IE 时出错,而完全相同的脚本在 Java-Selenium 中运行良好 - Error in launching IE with Python-Selenium while the exact same script works fine with Java-Selenium 使用 java-selenium 运行黄瓜测试时出现“java.lang.OutOfMemoryError”异常 - Getting "java.lang.OutOfMemoryError" exception while running a cucumber test using java-selenium 如何通过命令提示符/终端运行Java-Selenium测试用例? - How to run Java-Selenium test cases through command prompt/terminal? 如何使用java-selenium中的黄瓜bdd框架处理bootstrap下拉列表 - how to handle bootstrap dropdown using the cucumber bdd framework in java-selenium java - 如何在java-selenium中不使用findElement()或findElements()来检查元素的存在? - How to check the presence of an element without using findElement() or findElements() in java-selenium? 如何使用java-selenium webdriver检查zip文件是否成功下载? - How to check whether a zip file is successfully downloaded or not using java-selenium webdriver?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM