Forum Discussion

megha_phophalia's avatar
megha_phophalia
Contributor
7 months ago

How to close instance of application

My application is close but when I run my test ,it says -There are 2/3 running instance of application .New instance will not be launch and it failed the step .

I kill app through task manager also but still it shows the same thing .How to handle it and apply in keyword testing .

Here how I apply -If application window does not exist then it should launch the application -

But it did not open application and says -

Lemme know how to handle it.

  • JDR2500's avatar
    JDR2500
    Frequent Contributor

    Using VB Script check if the process is running and if so kill it:

    app_name = "Your process name here"
    If Sys.WaitProcess(app_name , 2000, 1).Exists Then
    Set p = Sys.Process(app_name )
    p.Terminate
    End If

    Put it in a loop if you think you may have more than one instance running and you can kill them all.  After creating the script you could call it easily enough from a keyword test.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Without knowing what your application is, whether it's a desktop app, windows service, how it's launched etc it's difficult to answer.

    If the process is reappearing in Task Manager, then it's most likely a windows process. 

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        ...and how is the application launched?

        It helps if you can provide more information, so that we can help you!

  • Check i have attached screenshot .

    We have option Run tested app and the application name,through this I am launching the app

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If you open and close your application manually, does it work?

    Your application is being launched from AppData folder and not from Program Files or Program Files (x86). Why is that?

    As an example, I suggest you test your code against Notepad, to see if it works. This will indicate whether there's an issue with your application or your code.

    • megha_phophalia's avatar
      megha_phophalia
      Contributor

      By default the application saved in AppData/local folder .

      Yes, Notepad get close with close and terminate.

      But why the application location matter for closing the application ?

      Also can you let me know what is the role of working folder ?

       

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        If it works fine using NotePad, then most likely it could be an issue with your application.

        There's plenty of reference of "working folder" if you search the internet.