Handling Image upload
Above is the code for upload image. Check the link to see the how the image upload option looks http://dropmocks.com/mEbKUV.
I tried the below code to upload image.
WebElement upload = driver.findElement(By.xpath(".//*[@rielyn upload.sendKeys("/Users/sathiyarengarajan/Desktop/images(1).jpeg"); driver.findElement(By.xpath(".//*[@id='cropandsave']")).click();
But it doesnot works.
irl last edited by user
As far as I know file uploads always need a
tag in the HTML. Your example HTML does not contain any. Often its hidden somewhere in the page, so that input element is not shown on the page. It could also be generated as you the
onclick eventfires. The example page you linked on dropmocks has no upload functionality, it does nothing (or I can't figure out how it should work).
Once you figured out where the
is located you can use your
sendKeys()code on that element instead and it should work. Also see https://stackoverflow.com/questions/3300580/webdriver-file-upload for more methods to upload a file with Selenium
I would ask advice of your development team, they surely can assist you to find the correct
tag and help making this test work.