0

I want to upload the file which can be in format of Png/Jpg/Apk/PPT/Pdf/Word to my web Service Project. Currently I am using Selenium WebDriver and Maven project with TestNG framework.

Issue Facing - I want to upload all files directly from my folder which is inside the project but outside SRS in Eclipse. I am getting an error of Null pointer exception or some time file not found error.

Below is the code which I am using to upload

AddNewAppPage lPO = new AddNewAppPage(driver);
ClassLoader classLoader = getClass().getClassLoader();      
File file = new File(classLoader.getResource("./Drivers/ABC.pdf").getFile());
Thread.sleep(3000);
lPO.getPresentationFile().sendKeys(file.toString());

Actually I don't want to give XPath of image or file upload of my system, I directly want to upload from the resource folder.

Project Explorer

JeffC
  • 22,180
  • 5
  • 32
  • 55
  • Possible duplicate of [How to upload file using Selenium WebDriver in Java](https://stackoverflow.com/questions/16896685/how-to-upload-file-using-selenium-webdriver-in-java) – JeffC Aug 31 '18 at 13:13
  • All caps doesn't really help. What would help is if you rewrote your question to address the specific issue you are having. If the issue is the file location, why does your code include uploading the file? Please edit your question and provide an [mcve] and more clearly describe what you are trying to do and the current issue. – JeffC Aug 31 '18 at 22:08

0 Answers0