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.
@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.
-
He is not talking about the Chrome browser, but the Java app on the right side of the image.João Farias– João Farias2019年08月01日 13:33:18 +00:00Commented Aug 1, 2019 at 13:33
Explore related questions
See similar questions with these tags.