I have a test to upload one file and then upload another file.

When first file is uploaded, java application is opened:
enter image description here
Steps to upload file:
- click on upload button
- using robot and keyPress, keyRelease to open file

But then I could not upload another file.
If close Java application manually, everything works Ok.
How to close it automatically?

2 Answers 2


On Unix, you can kill an application by name:

pkill [process name]

On Windows, you can use taskill:

taskkill /F /IM <processname>.<extension>

And to run it programmatically:

Runtime.getRuntime().exec("pkill [process name]")

This is very simple. You have to quit driver in tearDown mehthod with @AfterMethod annotation but there is few more things need to keep in mind like your test cases should be separate for each file upload and browser launch should be in setUp method. Please have a look below code to achieve it.

      public void setUp() 
      // Launch browser here   

    public void uploadFirstFile()
    // test case1

    public void uploadSecondFile()
    // test case2

   // Close the driver or exit the application

    public void tearDown() 

Hope it will help.

  • He is not talking about the Chrome browser, but the Java app on the right side of the image. Aug 1, 2019 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.