Forum Discussion

ep_savage's avatar
ep_savage
New Contributor
12 years ago

CustomScpExplorerForm or ScpCommanderForm in WinSCP

Hello,



I'm trying to write a simple TestComplete script that deals will open up WinSCP and just set the local and remote paths (in preparation of a much larger project).



So, as in practice, I recorded the actions first, then started to clean up the script for reuse purposes.



Unfortunately, I've come across something that I'm not sure how to deal with.  Apparently the form in WinSCP can be different.  For example, I have the following line in my script:



form = winSCP["VCLObject"]("ScpCommanderForm");



Mostly this worked.  But there have been a few times when TestComplete cannot find the ScpCommanderForm, which is because it doesn't exist.  It is coming across as CustomScpExplorerForm instead.



To fix this, I tried using the following:



form = winSCP["WaitVCLObject"]("*Form",10000);



This didn't work either.  I'm not sure how to go about trying to fix this.



After running WinSCP from TestComplete multiple times, I found out that about a quarter of the time, the form is CustomScpExplorerForm, and the rest it would be ScpCommanderForm.



Any suggestions would be appreciated.



Thank,

Paul















  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Paul, is it a requirement that you drive WinSCP via the GUI?



    My reason for asking is that I have had success using the WinSCP .Net Assembly via the CLR Bridge and it offers a nice, clean way of accessing WinSCP functionality without having to create GUI or shell processes.



    Anyway, just something to think about.



    Regards,

    Phil Baird
  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Paul, sorry I haven't replied sooner, I was on holiday on Friday :)



    The WinSCP .Net Assembly is basically a wrapper around the WinSCP executable and a Session maintains a non shell, background Process (you can see how it works using a decompiler such as ILSpy or dotPeek).



    Therefore, if you use the Assembly, WinSCP will need to be installed (exactly as if you were driving WinSCP via the GUI) and the Assembly needs to reside in the same directory as the WinSCP executable (on my machine this is C:\Program Files (x86)\WinSCP). You will also need to consider the version of WinSCP installed as the Assembly requires a leter version.



    One other thing is that like all .Net Assemblies, the WinSCP Assembly needs to be able to access all its referenced Assemblies. I found the easiest way to do this was to register the Assembly in the GAC rather than trying to indentify the referenced Assemblies and manually placing them where the WinSCP Assembly could find them.



    Hope this helps,

    Phil
  • ep_savage's avatar
    ep_savage
    New Contributor
    Hi Phil,



    Thank you for your response.  Since I use WinSCP all the time for manual testing, it never occurred to me to try to use something other than the GUI for automation.



    I'll look into using the WinSCP .NET Assembly through the CLR Bridge.  Thank you for that.



    I do have some quick, hopefully, questions.



    If I write my script using the Assembly, will other testers be able to run the tests on their machines without installing the assembly? with TestComplete or TestExecute?



    Thank you,

    Paul