Forum Discussion

arjun_ta's avatar
arjun_ta
Contributor
11 years ago

testedapps path

Hi,



i have added Excel in my tested apps, in my system its path is 



C:\Program Files\Microsoft Office\Office14\EXCEL.EXE



but in other system it is



C:\Program Files\Microsoft Office\Office10\EXCEL.EXE



how to make this generic? so that irrespective of Office version it should open the excel file that i want to work on??
  •  [VBScript]



    Set foundFiles = aqFileSystem.FindFiles("C:\Program Files\Microsoft Office\", "Excel.exe",True)

     If Not foundFiles Is Nothing Then

         While foundFiles.HasNext

           Set aFile = foundFiles.Next

            app = TestedApps.Add(aFile.path)

             TestedApps.Items(app).Params.ActiveParams.CommandLineParameters = Chr(34) & "C:\logins.xlsx" & Chr(34)

            TestedApps.Items(app).Run

       Wend

    End if



    'if u mean something by this then try this and let me know ur results
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Hi u can add tested app at runtime



    http://support.smartbear.com/viewarticle/57376/#ID0ELCAC



    and u can search for a testedapp and add it from ur script this will avoid dynamic filepath issue at several systems



     Set foundFiles = aqFileSystem.FindFiles("C:\Program Files\Microsoft Office\", "Excel.exe",True)

     If Not foundFiles Is Nothing Then

         While foundFiles.HasNext

           Set aFile = foundFiles.Next

            app = TestedApps.Add(aFile.path)

            TestedApps.Items(app).Run

       Wend
  • Hi ,



    along with the above code i want to open an excel file which i have already created in the path "C:\logins.xlsx"



    i e basically i was adding C:\logins in the command line parameters so that when the excel runs it opens the "logins" file



    how can i do this??

    i am coding in VB
  • murugans1011's avatar
    murugans1011
    Regular Contributor
     [VBScript]



    Set foundFiles = aqFileSystem.FindFiles("C:\Program Files\Microsoft Office\", "Excel.exe",True)

     If Not foundFiles Is Nothing Then

         While foundFiles.HasNext

           Set aFile = foundFiles.Next

            app = TestedApps.Add(aFile.path)

             TestedApps.Items(app).Params.ActiveParams.CommandLineParameters = Chr(34) & "C:\logins.xlsx" & Chr(34)

            TestedApps.Items(app).Run

       Wend

    End if



    'if u mean something by this then try this and let me know ur results
  • Hi Murugan,



    Thanks for the quick response , the above code is working fine.



    regards,

    Arjun
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    glad it helped.



    but  remember to remove the testedapp from the list when the testcase execution is completed or else everytime it adds the new testedapp at the beginning of the execution somthing like 



      Excel..Excel1..Excel2....so on 



    also u can use  somethin like this



    if Testedapp.Count>0 then

     

    .....Execute function



    End if
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    yes...add at the end in the above script



    Testedapps.Delete(app)  'app contains index no