I have a drag and drop zone for uploading images. If user does not drag and drop but clicks the area then the Windows File Explorer opens.
Here is the HTML for the drag and drop object
<div id="dropzone" action="" class="dropzone dz-clickable" xpath="1">
<div class="dz-default dz-message"><span><strong>Drop files here or click to upload. </strong></span></div></div>
- Css Selector = #dropzone
- JS path = document.querySelector("#dropzone")
- xpath = //*[@id="dropzone"]
- Full xpath = /html/body/div[3]/div/div/div/div[2]/form/div/div[2]/div[1]/div/div/div
Here's my attempt
public void fileUpload() throws InterruptedException {
// FILE UPLOADING USING SENDKEYS ....
WebElement deal_image_input = driver.findElement(By.xpath("//div[@id='dropzone']"));
deal_image_input.click(); //tried with and without this step
deal_image_input.sendKeys("C:\\ilmlsAutomationAddIns\\image1.png");
Thread.sleep(1000);
deal_image_input.click();
deal_image_input.sendKeys("C:\\ilmlsAutomationAddIns\\image2.png");
Thread.sleep(1000);
deal_image_input.click();
deal_image_input.sendKeys("C:\\ilmlsAutomationAddIns\\image3.png");
}
Here's the error I get when it tries to execute a sendKeys step
org.openqa.selenium.ElementNotInteractableException: element not interactable
(Session info: chrome=96.0.4664.110)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-C4QF06B', ip: '172.16.1.74', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 96.0.4664.110, chrome: {chromedriverVersion: 96.0.4664.45 (76e4c1bb2ab46..., userDataDir: C:\Users\Kelly\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:56745}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 30f4fb05878179181cbafcb0a369f596
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
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 Pages.MerchantHomePage.fileUpload(MerchantHomePage.java:179)
at Pages.MerchantHomePage.general_Inputs(MerchantHomePage.java:174)
at Pages.MerchantHomePage.post_cashoff_deal(MerchantHomePage.java:441)
at Tests.DealPageTest.addCashOffDeal(DealPageTest.java:25)