w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
selenium upload file java ChromeDriver/FirefoxDriver

A "*.jpeg"-File isn't a valid .jpg file.

Can you show at least the html-Code of the fileUpload?

Are you sure your JVM has access to the file? Maybe you should add the file to your resources-folder. If your file is stored in "[...]workspaceprojcetnamesrc est esources" this should work:

String pathToUpload = "/Lighthouse.jpg";
URL url = MYCLASSNAME.class.getResource(pathToUpload);
String filePath = url.getFile();
File imgToUpload = new File(filePath);
String absolutePath = imgToUpload.getAbsolutePath();

Be careful: 'Myclass' has to be replaced with your current classname.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.