trying to upload a an image file using Java selenium
Hi all, I am trying to upload a an image file using Java selenium
below is the code:
first approach:
WebElement upload_file = driver.findElement(By.xpath("xpath of upload button")); upload_file .click(); // just passed a delay, it does not crate a problem I can remove it java.lang.Thread.sleep(2000); //full file path present in my local machine uplaod_file.sendKeys("C:\\Users\\Lenovo\\Pictures\\Files\\image.jpg"); System.out.println("File is Uploaded Successfully");
Issue observed :org.openqa.selenium.ElementNotInteractableException: element not interactable
Second approach:
By upload_file_button = By.xpath("xpath of upload button"); explicit_wait.until(ExpectedConditions.elementToBeClickable(upload_file_button)); driver.findElement(upload_file_button).click(); java.lang.Thread.sleep(2000); ((WebElement) upload_file_button).sendKeys("C:\\Users\\Lenovo\\Pictures\\Files\\image.jpg"); System.out.println("File is Uploaded Successfully");
Issue observed : org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: xpath of upload button (tried for 20 second(s) with 500 milliseconds interval)
need help for same, please do correct me If I am wrong.