gpt4 book ai didi

java - 错误: Caught exception [ERROR: Unsupported command [selectFrame | index=1 | ]] while exporting code from Selenium IDE to Webdriver

转载 作者:行者123 更新时间:2023-12-02 11:03:15 33 4
gpt4 key购买 nike

导出的代码:

 public void testUntitledTestCase() throws Exception {

driver.get("URL");

driver.findElement(By.xpath("//button[@id='add-items']")).click();

driver.findElement(By.id("item_title")).sendKeys("Automation");

driver.findElement(By.id("item_cat_id")).click();

// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | index=1 | ]]

driver.findElement(By.linkText("Cat1")).click();

// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | relative=parent | ]]

driver.findElement(By.xpath("//button[@id='item-save']"").click();
}

错误发生在 Iframe 打开的位置。该应用程序有一个表单,其中某些字段具有按钮 - 单击这些按钮时会在弹出窗口(Iframe)中打开另一个 View 。我需要从 Iframe 中选择元素。它抛出一个错误:

// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | index=1 | ]].
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | relative=parent | ]]

最佳答案

您确定它是 iFrame 吗?

如果是尝试获取 iFrame“名称”。将帮助您将注意力集中在正确的 Iframe/窗口/选项卡上。

希望这对你有帮助:)

List ele = driver.findElements(By.tagName("iframe")); System.out.println("Number of frames in a page :" + ele.size());

for(WebElement el : ele){ //返回帧的Id。

        System.out.println("Frame Id :" + el.getAttribute("id"));
//Returns the Name of a frame.

System.out.println("Frame name :" + el.getAttribute("name"));
}

关于java - 错误: Caught exception [ERROR: Unsupported command [selectFrame | index=1 | ]] while exporting code from Selenium IDE to Webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51173105/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com