Now in the application that i have to automate, there's a jhtml Area element. This is a sample jhtml area: http://pietschsoft.com/demo/jhtmlarea/.

So the jhtml area has two elements for the text you enter. I have tried entering text using the text area tag. But doesn't work out. Any ideas? enter image description here

  • Can you please past in your code here... We can't help you from scratch... We can identify the problem from the code.. Mar 26, 2017 at 17:19

2 Answers 2


As per given sample URL, if you observe the HTML of JHTML it inside the iframe, so to enter the text inside you have to first switch to the iframe and than enter the text. Your code may look like below.

WebElement iframe = driver.findElement(By.xpath("//iframe")); // xpath of the iframe

// Now enter the text in text area.
driver.findElement(By.xpath("//body")).sendKeys("Whatever text you want to send");
  • Unfortunately that doesn't work. If you see the image, the iframe has the <body> tag. But the text area, which has the text, is outside of it.
    – Swastik
    Mar 24, 2017 at 10:20
  • If you inspect the JHTML and edit text under body tag it will reflect the text in JHTML, but if you edit the textarea and enter the text there it does not reflect in JHTML. So you will have send the text inside the body tag. Mar 24, 2017 at 11:25
  • Sending to the body using sendkeys doesn't take the change. Even tried highlighting the body and using some action keys by simulating keyboard events. No luck.
    – Swastik
    Mar 24, 2017 at 13:02

As per your example URL, please try the following code in order to switch to the iframe for the jHTMLArea and manipulate the body text. The code is relatively straight forward, prepping the driver, navigate to the page, switching to the iframe and then manipulating the body, asserting the change and quitting the driver instance.

public void jarea() {
    String test = "Hello";
    System.setProperty("webdriver.chrome.driver", "C:/Automation/Chromedriver.exe");
    WebDriver d = new ChromeDriver();


    WebElement iframe = d.findElement(By.xpath("//iframe")); 

    WebElement jAreaBody = d.findElement(By.xpath("/html/body"));
    assertEquals(jAreaBody.getText(), test);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.