Advance qtp scripting and qtp tips

By | June 2, 2009

Advance qtp scripting and qtp tips:
Friends, I want to share some solutions of problem that my junior colleague faced during automation using QTP.
I hope you will find this solution very helpful if you also stuck in similar kind of situation and also you will get more advance knowledge of QTP.

Problem:- 1. How to login in one machine using Telnet from QTP script.
Solution:- Following is the script for above problem.
——————————————————
Dim host,username,password

Host = myhost

Username = myname

Password = mypwd

Function do_telnet (host,username,password)

objSh.Run “telnet ” & host

wscript.sleep 2000

objSh.AppActivate “telnet”

wscript.sleep 2000

objSh.SendKeys username+chr(13)

wscript.sleep 2000

objSh.SendKeys password+chr(13)

wscript.sleep 2000

objSh.SendKeys “exit”+chr(13)

end function
——————————————–
Note: Please keep in mind that this script will not work, if you write it directly in “test” file of qtp. You have to make one function and embed this script in that function and you have to put it in VBS file.
Than just call that function from your “test” file of QTP. Don’t forget to attach this file to your test file of QTP. If you don’t know how to link VBS to test file of QTP, Please refer 13th question of this page.

If you find any issue with this script, you can comment me. Please don’t forget to share your experience.
I also want to share some tips and tricks to you.

Tips and tricks 1:– After completion of development and 100% testing of your automation project, If your project consume huge memory, than you can delete snapshots folders from Action0 and Action1 folders.
(Snapshots folder contains the snapshots captured by QTP. Warning! – Don’t delete these folders if you want to create checkpoints in project.).
Your project size will be lesser by 60 to 70% percentages after deleting these folders.

This tip is very much useful for those, who have to frequently transfer the automation project between on-shore and off-shore.

So thats all!!!If you have any other tips for making project compact you are welcome to share.

If you like this article, You can subscribe through mail.

6 thoughts on “Advance qtp scripting and qtp tips

  1. Anonymous

    I like your tips. thanks..
    can disable active screen during recording?

    Reply
  2. Automation Expert...

    Hi buddy,
    If you want to customize active screen, before recording. You can do. Go to tools->option and go to active screen tab. You can also disable active screen if you want.
    Let me know, you are satisfied with answer or not.

    Reply
  3. Anonymous

    Can we handle telnet connection using dynamic delay instead of static delays.

    Reply
  4. ITfreak

    That was really very interesting . I have a doubt which i was wondering could be solved by Automation.I use Windows 7 machine and Putty to connect to UNIX servers. I am required to FTP certain files from those server to my local windows machine. For this purpose i use a FTP client like FileZilla or WinSCP.

    However, i want to create a script , that would –
    1. Connect to unix server from my windows machine.
    2. FTP file from certain directories to windows machine.
    3. Terminate the connection after the FTP download is complete.
    4. This should occur periodically.

    Please guide me in creating such a script if possible

    Reply
  5. ITfreak

    That was a very interesting articl. I was wondering , whether i could automate a similar task.I use Windows 7 machine and Putty to connect to UNIX servers. I am required to FTP certain files from those server to my local windows machine. For this purpose i use a FTP client like FileZilla or WinSCP.

    However, i want to create a script , that would –
    1. Connect to unix server from my windows machine.
    2. FTP file from certain directories to windows machine.
    3. Terminate the connection after the FTP download is complete.
    4. This should occur periodically.

    Please guide me in creating such a script, if possible

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *