3

I am trying to enter the text in a textbox, but I am getting an error as follows

org.openqa.selenium.InvalidElementStateException: Element must not be hidden, disabled or read-only

Anybody can help me regarding this issue to be fixed.

3
  • Does the page by chance have a loading modal?
    – Paul Muir
    Commented Dec 3, 2015 at 2:16
  • No, it doesn't. The steps are like this 1. Login 2. MouseOver 3. Select Frame 4. Enter text, but here i am unable to enter the text
    – Bunny
    Commented Dec 4, 2015 at 7:50
  • Did you check it - stackoverflow.com/questions/11858366/… Might be your issue same as this.
    – Sachin
    Commented Feb 14, 2016 at 13:13

6 Answers 6

5

You may try with javascriptexecutor- Check below code-

driver.switchTo().frame("WallItemItemDetail_ifr");
// select the editor and do the input 

WebElement TextBox = driver.findElement(By.id("tinymce"));
String input= "editor done";
TextBox.getAttribute("name");
JavascriptExecutor jst= (JavascriptExecutor) driver;
jst.executeScript("arguments[1].value = arguments[0]; ", input, TextBox);   

// switch back to the default window 
driver.switchTo().defaultContent();
2
  • 1
    Your answer would be more helpful if you explained how this would fix the OP's problem.
    – Kate Paulk
    Commented Apr 14, 2016 at 11:23
  • @kate Paulk - Sometimes some browsers like Internet Explorer sendKey is not working to enter text in the text box. In this situation we will use javaScriptexecutor which is the best solution for sendKeys. I think you are well known about how to use javaScript.
    – Bharat Mane
    Commented Dec 9, 2016 at 12:53
2

Include what you are using to select the IWebelement on the page in the question above.

  1. Try opening the html page with the textbox in chrome
  2. Hamburger menu > More tools > Developer tools,
  3. Right click on the textbox > Inspect element.
  4. Right click > Copy css text/Copy XPath text.
  5. Then compare the result with what your using to select the element.

Is the xpath/css the same? Change it to what you copied. Does it work now? If you are selecting by id? Does that match? Change it to the id in the highlighted text, does it work now?

1

@Bunny - Give a try to below solution :

element_select_frame.sendKeys("");
textBox.sendKeys("Bunny, Pls Enter your text in text box");

Hope it will help ! Come up if you have queries.

1

Here is the snippet of the code for WebDriver.

  driver.switchTo().frame("WallItemItemDetail_ifr");

// select the editor and do the input 

 driver.findElement(By.id("tinymce")).sendKeys("editor done");

// switch back to the default window 

 driver.switchTo().defaultContent();
0

Is the element you are selecting the actual element which receives the text? Without being able to see the html you are working on, you may be sending the text to a container for the actual input element.

0

This is the problem faced by automation engineers in many qa testing companies while entering data to adisabled webelement. This can be done by using java script.

Below is one way to set text This is the problem faced by automation engineers in many qa testing companies while entering data to an webelement disabled. This can be done by using java script.

Below is one way to set text 'testuser' to a webElement 'userNameTxt' :

//find the element in selenium webdriver WebElement userNameTxt = driver.findElement(By.Id("username"));

// set the text JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("arguments[0].value='testuser'", userNameTxt);

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.