I'm trying to access iFrame
<iframe id="frame1" style="width: 100%; height: 100%; display: block;" tabindex="100">
<html>
<head xmlns="http://www.w3.org/1999/xhtml">
<body id="tiny1" contenteditable="true" onload="window.parent.get('frame1').onLoad.dispatch();">
<p/>
</body>
</html>
</iframe>
And I want to sendKeys()
to the body with id=tinymce
. But when I tried to switchTo().frame
, it does not work.
My Java code:
public void enterArea(String object, String content){
String driverWindows = driver.toString();
driver.switchTo().frame(selenium.driver.findElement(By.xpath("//*[@id='frame1']")));
String driverIFrame = driver.toString();
WebElement contentTextArea = (new WebDriverWait(driver, 3))
.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='tiny1']/p")));
contentTextArea.sendKeys(content);
driver.switchTo().defaultContent();
}
The two driverWindows
and driverIFrame
always return the same string, it means the web driver
has not switched, right?
Could you help me access to elements? Please do let me know if require any further details.