How to pass many pages of data(say 100 page) to tiny mce using web driver?

The document which i want to copy paste to tiny mce is formatted, it has 100 pages, bold characters, Table and special characters too. I wan to copy paste this document to tiny mce which is available in our application.

Using sendKeys and executeScript() method i am able to send some words but not sure how to send many characters

Below is the code which i am using to send words
WebElement tinymce_iFrame = driver.findElement(“docAnnotation_content-232415_ifr”));
WebElement editorBody=driver.findElement(By.tagName(“body”));
((JavascriptExecutor)driver).executeScript(“arguments[0].innerHTML = ‘<h1>Set text using innerHTML</h1>'”, editorBody);

Please help me to copy paste 100 pages of data from formatted word document to tiny mce using webdriver.

Default Asked on December 17, 2015 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)

    I investigated on this, and i got solution that is, first we need to read text file data into string using ‘bufferedReader’ and we can send string data to tinyMCE using send keys. Below is the code,

    method to read data from .txt file to string,

    public String readFile() throws Exception{
    BufferedReader br = new BufferedReader(new FileReader(path));
    String line = null;
    StringBuilder sb = new StringBuilder();
    String ls = System.getProperty(“line.seperator”);

    while((line = br.readLine())!=null){

    return (sb.toString());

    code to send data from string to tinyMCE(to switch control to tinyMCE we should use iFrames()),

    WebElement editorBody=driver.findElement(By.tagName(“body”));
    String data = readFile();

    Above code is sending data to tinyMCE but i am facing below two challenges,
    1. After entering some specific lines scrollbar will appear on tinyMCE, but webDriver will not identify this scrollbar and data is entering on other fields other than tinyMCE.
    2. I am sending data from .txt file so unable to send richtext. Need to investigate how to send data from .doc file.

    If any one knows solution for the above question, please help me.

    Default Answered on December 19, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.