Handling tinyMCE editor with Selenium Webdriver

Here is how to use Selenium Webdriver with tinyMCE:

The tinyMCE editor creates its own iframe, so before selenium is able to perform any task or action on it, it has to first switch the control to the iframe and then start execution.
Here is how to switch this:

// Select the iframe
driver.switchTo().frame("yourtxtarea_ifr");
// select the editor nad do the input 
 driver.findElement(By.id("tinymce")).sendKeys("Dummy text");

Now after the WebDriver is all done with its actions on the editor it needs to switch back to the default window to continue with the rest of the script. Below is the sample code to switch back to the default window:

// switch back to the default window 
driver.switchTo().defaultContent();

Hope this helps. Please let us know in case of any issues.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s