1

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?

João Farias
11.2k2 gold badges21 silver badges41 bronze badges
asked Mar 3, 2019 at 17:35

2 Answers 2

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]")
answered Mar 4, 2019 at 6:21
0

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.

 @BeforeMethod
  public void setUp() 
 { 
 // Launch browser here 
  }
 @Test
 public void uploadFirstFile()
 {
 // test case1
 }
 
 @Test
 public void uploadSecondFile()
 {
 // test case2
 }
 // Close the driver or exit the application
 @AfterMethod
 public void tearDown() 
 {  
    driver.quit();
  }

Hope it will help.

João Farias
11.2k2 gold badges21 silver badges41 bronze badges
answered Mar 4, 2019 at 5:05
1
  • He is not talking about the Chrome browser, but the Java app on the right side of the image. Commented Aug 1, 2019 at 13:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.