如何使用java在Selenium WebDriver中处理iframe<div>
<iframe id="cq-cf-frame ">
<iframe id="gen367">
<body spellcheck="false" id="CQrte" style="height: 255px; font-size: 12px; font-family:tahoma,arial,helvetica,sans-serif; background-image: url("/libs/cq/ui/widgets/themes/default/ext/form/text-bg.gif"); background-repeat: repeat-x; background-attachment: fixed;">
<p>4t43t4<br></p>
</body >
</iframe>
</iframe> </div>在这种情况下有一个iframe下iframe。而且我必须选择外部iframe去内部iframe并写入内部的身体iframe。接下来,我必须从内iframe到外出来iframe并单击OK按钮(位于外部iframe)。以下是我的代码/*Line 1 */ driver.switchTo().frame("cq-cf-frame");/* 2 */ driver.findElement(By.css("#extdd-9 > div.tblRow > input.edititem").click();/* 3 */ driver.switchTo().Frame("cq-gen379");/* 4 */ driver.findElement(By.id("CQrte").sendKeys("Tnx"); /* 5 */ selenium.selectFrame("relative=up"); /* 6 */ driver.findElement(By.xpath("//button[text()='OK']")).click();以下是我的问题:我的测试代码工作正常,直到第4行,即写入正文,但我想从内到外出来,iframe它说//button[text()='OK']没有找到元素。我尝试使用索引,父,亲,但没有运气。注意:如果我没有选择内框(cq-gen379)。我可以点击OK按钮。
添加回答
举报
0/150
提交
取消