This is my below code I am executing
driver.findElement(By.xpath("//label[starts-with(text(),'Create Part...')]")).click();
driver.manage().timeouts().implicitlyWait(70, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(70, TimeUnit.SECONDS);
String parentWindowHandler = driver.getWindowHandle(); // Store your parent window
String subWindowHandler = null;
Set<String> handles = driver.getWindowHandles(); // get all window handles
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler); // switch to popup window
WebElement element = driver.findElement(By.xpath("//select[@id='Type-Field']//following-sibling::div//div[@class='selectize-input items full has-options has-items']"));
element.clear();
element.sendKeys("Suba");
I am trying clear the default value in the field and giving some value through sendkeys. Field gives dropdown suggestions on entering the value.
It is throwing error at element.clear() line.
Stack trace:
Exception in thread "main" org.openqa.selenium.InvalidElementStateException:
invalid element state: Element must be user-editable in order to clear it.
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.38.552522
(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 6.1.7601 SP1
x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 34 milliseconds
Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10
09:00:17 -0800'
System info: host: 'TMIC-PCS2200', ip: '3.235.34.200', os.name: 'Windows 7',
os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false,
mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome=
{chromedriverVersion=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),
userDataDir=C:\Users\KT0047~1\AppData\Local\Temp\scoped_dir11272_22577},
takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false,
handlesAlerts=true, hasTouchScreen=false, version=66.0.3359.181,
platform=XP, browserConnectionEnabled=false, nativeEvents=true,
acceptSslCerts=false, acceptInsecureCerts=false,
locationContextEnabled=true, webStorageEnabled=true, browserName=chrome,
takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true,
setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 742100fb9b41517012003fc5abe12b71
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)
Please help me resolving my issue. I am using Selenium 3.3.1 version.
HTML code
<div class="selectize-input items full has-options has-items" data-dropdown-direction="down">
<div data-value="Part" class="item">Part</div>
<input type="text" autocomplete="off" tabindex="1" style="width: 4px; position: relative; left: 0px; opacity: 0; z-index: -10000;">
::after
</div>
Here Part is the default value.