I wanted to select an Iframe and Enter values in the Body . I am trying with the below code.
HTML code:
<iFrame id="4564654_content_ifr">
<html>
<head>
<body id="tiny">
<div aria-lable="New Compose body">
<br>
</div>
</body>
</head>
</html>
</iFrame>
Selenium code:
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[contains(@id,'content_ifr')]")));
driver.findElement(By.xpath("//*[@id='tiny']/div[1]")).sendKeys("Happy New IFrame");
But I could not able to enter values.
Can anybody help me with this?
Try the below May help you.
Instead of sending keys, you can set
innerHTML
directly.If you are testing some kind of WYSIWYG editors like TinyMCE, feel free to have a look at this article:
Test WYSIWYG editors using Selenium WebDriver
Then you might be able to set content through editor's API directly. It's known to have issues with
sendKeys
in Firefox, but should be fine with Chrome or PhantomJS.