首页 > 解决方案 > 在编写 XPATH 时,我可以访问 #doucment..inside #document 我必须在下面的 html/body 中输入我的 ntml 页面

问题描述

这是我的 html 页面,请帮忙

和下面的我的xpath:(//span[text()='Information']//following::div[contains(@class,'edit-area')])[1]/iframe

bt 当我运行 mr 脚本时,它显示部分窗口中不存在 iframe。即使我尝试使用 WHEN 搜索框架,我也尝试获取显示 iframe 大小为 = 0 的框架大小

标签: javascripthtmlseleniumxpathiframe

解决方案


WebElement frame =driver.findElement(By.xpath("(//span[text()='Information']//following::div[contains(@class,'edit-area')])[1]/iframe"));
          System.out.println(frame);
         driver.switchTo().frame(frame);
         WebElement elem = driver.findElement(By.xpath("/html/body/p"));
          System.out.println(elem);


         Actions actions = new Actions(driver);
         actions.moveToElement(elem);
         actions.click();
         actions.sendKeys("SOME DATA");
         actions.build().perform();

         System.out.println("finished");

推荐阅读