I tried to upload a file but it throws an exception. The upload button is custom made. I even tried to click it but it gets stuck there.
new WebDriverWait(driver,100).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@id='divProfileSetting']/div/div/div/div[7]/div[2]/div/div/div/label/span")));
WebElement UploadingFile1 = driver.findElement(By.xpath("//div[@id='divProfileSetting']/div/div/div/div[7]/div[2]/div/div/div/label/span"));
//UploadingFile1.click();
UploadingFile1.sendKeys("E:\\Hatha.jpg");
Exception:
Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: element not interactable
(Session info: chrome=74.0.3729.108)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'RAUNAK-MA', ip: '172.27.242.131', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.46.628402 (536cd7adbad73a..., userDataDir: C:\Users\RAUNAK~1.MAS\AppDa...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:55361}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 74.0.3729.108, webStorageEnabled: true}
Session ID: 53e0b557906a50d6f51f9aa0c2bf1a14
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:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:106)
at newpackage1.flightdeckau.main(flightdeckau.java:96)
HTML:
<div class="span12 logouploadContainer">
<input type="file" id="file" name="file" tabindex="-1" style="position: fixed; left: -9999px;">
<div class="bootstrap-filestyle" style="display: inline;" tabindex="0">
<input type="text" class="input-large" disabled="">
<label for="file" class="btn btn-primary">
<i class=" icon-white icon-folder-open" data-original-title="" title=""></i>
<span data-original-title="" title="">Choose File</span>
</label>
</div>
<div id="logo-div" class="hidden">
<button type="button" id="btnResetLogo" class="btn" style="margin-left: 5px;" data-original-title="" title="">Remove</button>
<div id="imgContainer" style="height: 100%; width: 100px; padding: 5px; overflow: hidden;">
<img alt="Client Logo" id="imgClient" src="">
</div>
</div>
</div>
Tried with waiting for the element as well but seems like it is having some problems.