0

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?

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.

0

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]")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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