Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
1.5k views
in Selenium by
ERROR MESSAGE WHEN TRYING TO CLEAR A TEXT BOX:
================================================
 
using 
 
driver.findElement(By.id("renderForm")).clear();   Here renderForm is ID of Text Box.
 
Exception in thread "main" org.openqa.selenium.InvalidElementStateException: invalid element state: Element is not currently interactable and may not be manipulated
  (Session info: chrome=50.0.2661.102)
  (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.2 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 24 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'udhai', ip: '192.168.1.4', os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.8.0_91'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4), userDataDir=C:\Users\admin\AppData\Local\Temp\scoped_dir10084_1752}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=50.0.2661.102, platform=WIN8, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 6ed5741b953bfed7ed0e0483069744a3
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.clear(RemoteWebElement.java:140)
at newpackage.MyClass.main(MyClass.java:125)
 

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)
make sure that element is not disabled/its of the tagName input and type is of text.
by
Yes its true ,The element Textbox is disabled.  I tried various methods to enable the text box but not able to Enable it.Is the following correct to enable the text box.

((JavascriptExecutor) driver).executeScript("arguments[0].enabled = true", personalinfo_email_textbox);
by The go-to Tester (181 points)
Try forcing your value into textbox.

((JavascriptExecutor)driver).executeScript("arguments[0].value='[email protected]'",  personalinfo_email_textbox);
by
Thanks Mayur.   I got the solution to the problem.Yes it was Disabled .That's true.But the reason I could not enable it using

((JavascriptExecutor) driver).executeScript("arguments[0].enabled = true", personalinfo_email_textbox);

was that something is wrong with the locator id "renderForm".I am sure I copied it correctly using inspect element.

Now I tried with name instead of id and its working fine.Both enabling and Clearing.

Thanks Mayur for your answer.

Regards
Uday
...