我是selenium webdriver&的新成员。我想用Rich文本编辑器输入iframe:
<iframe frameborder="0" aria-describedby="cke_24" title="Rich text editor, Post_description" src="" tabindex="-1" allowtransparency="true">
#document
<html dir="rtl" lang="ar" class="CSS1Compat" contenteditable="true">
<head></head>
<body spellcheck="false" class="cke_show_borders">
<p>
</p>
</body>
</html>
</iframe>
我用过这个:
WebDriver driver;
WebElement frame = driver.findElement(By.xpath("//iframe[@title = 'Rich text editor, Post_description']"));
driver.switchTo().frame(frame);
WebElement editable = driver.switchTo().activeElement();
editable.sendKeys(desc);
driver.switchTo().defaultContent();
但它什么也没做......它只是输入白线......有什么帮助吗?
答案 0 :(得分:1)
WebElement frame = driver.findElement(By.xpath("//iframe[@title = 'Rich text editor, Post_description']"));
driver.switchTo().frame(frame);
WebElement body = driver.findElement(By.tagName("body"));
body.sendKeys("Hello world");
driver.switchTo().defaultContent();