Pages

Monday, March 16

File Handling in QTP - Part 1


Hello Friends!

In this post, we'll see how to handle files using vbscript in QTP.
We'll cover -

  • How to create new file and write data
  • How to open existing file and read data
  • How to open existing file and append data
  • How to delete an existing file

Okie... so lets talk about File System Object (FSO) first. Actually all these things will be done using FSO only!


What is File System Object (FSO)?

File System Object is used to -

1.  creation, manipulation and deletion of text files
2. create, move and Delete folders on hard disk


FSO is the short name for  File System Object.  The FSO Object Model has a rich set of properties, methods and events to process folders and files.

How to create a file?

yeah.. here we go!

Suppose you want to create a file called "myFile.txt" on C:\ drive

Dim objFSO, file_path
file_path = "C:\myFile.txt"

Function CreateFile(file_path)
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set CreateFile = objFSO.CreateTextFile(file_path, True)
End Function

Call CreateFile("C:\myFile.txt")

And it's done! Hunt your C:\ drive.... myFile.txt will be there!

Ggrayyyytt!!

Now, look at this part..

objFSO.CreateTextFile(file_path, True)
objFSO - is an object of type FileSystemObject
CreateTextFile - is a method of FSO
file_path - is the path/location of you file
True - true means - if the file is already there, it will be overwritten.

You can write False also. In that case if file is already there, it'll not be overwritten, and it'll give you following error.




To test this, follow these steps.... n picture'll be clear to you!
  • run the above code
  • open the file and write your name, save and close
  • run the above code again (same)
  • open the file and see- your name will not be there because it's overwritten
  • now change this line in above code and run again.
  • Set CreateFile = objFSO.CreateTextFile(file_path, False
  • this time you will get the error because file is already there and because of False, it will not be overwritten.


Tired?? 

No worries!! In next part of this post, we will reveal all the methods of FSO.

In case of any queries, please post your comments.

151 comments:

  1. Abhikansh ...Thanks a Ton for sharing your knowledge...with us...i have learned a lot..

    -Pankaj

    ReplyDelete
  2. hi this is very useful...

    ReplyDelete
  3. Function CreateFile(file_path)
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set CreateFile = objFSO.CreateTextFile(file_path, True)
    End Function

    Can you please let me know why did you use Set before "CreateFile = objFSO.CreateTextFile(file_path, True)"

    ReplyDelete
  4. what is the meaning testcomplete in automation testing? how can i give the answer to interviewer

    ReplyDelete
  5. TestComplete is a Regression/Functional Testing tool like QTP.

    ReplyDelete
  6. I tried this code to create a file ,file is not created and Testscript doesnt fail it shows done. wht should i do ?

    ReplyDelete
  7. @Aanvi s - make sure you have rights to create a file on given path. try to create a file manually first.

    ReplyDelete
  8. thanks for sharing wonderful blog and keep updating more useful information like this. and you are doing great article.
    Software Testing Training in Chennai

    ReplyDelete

  9. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.

    SAP training in Chennai

    ReplyDelete
  10. thanks for sharing wonderful blog and keep updating more useful information like this. and you are doing great article.
    qtp training in chennai

    ReplyDelete
  11. Your style is very unique compared to other people I've read stuff from. Thanks for posting when you've got the opportunity, Guess I'll just bookmark this web site. gmail login

    ReplyDelete
  12. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete
  13. Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
    dotnet training in bangalore

    ReplyDelete
  14. I wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.


    oracle training in Bangalore

    ReplyDelete
  15. Thanks The information which you provided is very much useful and easy to learn as well... keep rocking and updating... looking further..
    Austere Technologies |Internet Of Things

    ReplyDelete
  16. Really great blog, it's very helpful and has great knowledgeable information.

    Best Cloud Solutions | Austere Technology Solutions

    ReplyDelete
  17. Great article, really very helpful content you made. Thank you, keep sharing.

    Best Software Security Services | Austere Technology Solutions

    ReplyDelete
  18. AWS Training in Bangalore - Live Online & Classroom
    myTectra Amazon Web Services (AWS) certification training helps you to gain real time hands on experience on AWS. myTectra offers AWS training in Bangalore using classroom and AWS Online Training globally. AWS Training at myTectra delivered by the experienced professional who has atleast 4 years of relavent AWS experince and overall 8-15 years of IT experience. myTectra Offers AWS Training since 2013 and retained the positions of Top AWS Training Company in Bangalore and India.


    IOT Training in Bangalore - Live Online & Classroom
    IOT Training course observes iot as the platform for networking of different devices on the internet and their inter related communication. Reading data through the sensors and processing it with applications sitting in the cloud and thereafter passing the processed data to generate different kind of output is the motive of the complete curricula. Students are made to understand the type of input devices and communications among the devices in a wireless media.

    ReplyDelete
  19. Wow, Excellent post. This article is really very interesting and effective.The article you have shared here very awesome. I really like and appreciated your work. I read deeply your article, the points you have mentioned in this article are useful.

    iOS Training

    ReplyDelete
  20. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command

    java training in chennai | java training in bangalore

    java online training | java training in pune

    selenium training in chennai

    selenium training in bangalore

    ReplyDelete
  21. Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing.
    AWS Training in Chennai |Best Amazon Web Services Training in Chennai
    AWS Training in Rajaji Nagar | Amazon Web Services Training in Rajaji Nagar

    Best AWS Training Institute in BTM Layout Bangalore ,AWS Coursesin BTM


    ReplyDelete
  22. Very informative blog, really helpful. Thank you.

    cs course eligibility | ISFS

    ReplyDelete
  23. Wow...Excellent informative blog, really helpful. Thank you.

    Best CMA Training in hyd | ISFS

    ReplyDelete
  24. I really like the dear information you offer in your articles. I’m able to bookmark your site and show the kids check out up here generally. Im fairly positive theyre likely to be informed a great deal of new stuff here than anyone
    python training in rajajinagar
    Python training in btm
    Python training in usa
    Python training in marathahalli

    ReplyDelete
  25. QTP training in bangalore,QTP training in Bangalore offered by Training in Bangalore with 100% placement assistance. Best QTP training in Bangalore with certified experts
    qtp training in bangalore

    ReplyDelete
  26. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    Devops training in sholinganallur
    Devops training in velachery
    Devops training in annanagar
    Devops training in tambaram

    ReplyDelete
  27. IOT Training in Bangalore - Live Online & ClassroomStudents are made to understand the type of input devices and communications among the devices in a wireless media.IOT Training course observes iot as the platform for networking of different devices on the internet and their inter related communication.

    ReplyDelete
  28. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa interview questions and answers
    automation anywhere interview questions and answers
    blueprism interview questions and answers
    uipath interview questions and answers
    rpa training in chennai

    ReplyDelete
  29. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

    angularjs Training in electronic-city

    angularjs online Training

    angularjs Training in marathahalli

    angularjs interview questions and answers

    angularjs Training in bangalore

    angularjs Training in bangalore

    ReplyDelete
  30. Your article gives lots of information to me. Thanks for sharing.
    acca course in hyderabad | ISFS

    ReplyDelete

  31. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    Advanced AWS Interview Questions And Answers, Top 250+AWS Interviews Questions and Answers 2018
    Advanced AWS Interview questions and answers | Top 110 AWS Interview Question and Answers
    Advanced AWS Training in Bangalore | Best Amazon Web Services Training in Bangalore
    Advanced AWS Training in Pune | Best Amazon Web Services Training in Pune
    Advanced AWS Online Training | Best Online AWS Certification Course in india

    ReplyDelete
  32. I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Many thanks!
    python course in pune
    python course in chennai
    python course in Bangalore

    ReplyDelete
  33. I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog.

    rpa training in chennai |rpa course in chennai|
    rpa training in bangalore | best rpa training in bangalore | rpa course in bangalore | rpa training institute in bangalore | rpa training in bangalore | rpa online training

    ReplyDelete

  34. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.

    AWS TRAINING IN BANGALORE|NO.1AWS TRAINING INSTITUTES IN BANGALORE

    ReplyDelete
  35. If you want to play like me and not lose, you should try playing BGAOC. free gambling with us Playing here you not only win but also get a lot of fun.

    ReplyDelete
  36. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    Advanced AWS Training in Bangalore | Best Amazon Web Services Training Institute in Bangalore
    Advanced AWS Training Institute in Pune | Best Amazon Web Services Training Institute in Pune
    Advanced AWS Online Training Institute in india | Best Online AWS Certification Course in india
    AWS training in bangalore | Best aws training in bangalore

    ReplyDelete
  37. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's. 
    rpa training in bangalore
    rpa training in pune
    rpa online training
    best rpa training in bangalore

    ReplyDelete
  38. This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
    Best Devops online Training
    Online DevOps Certification Course - Gangboard
    Best Devops Training institute in Chennai

    ReplyDelete
  39. Greetings from Florida! I’m bored at work, so I decided to browse your site on my iPhone during lunch break. I love the information you provide here and can’t wait to take a look when I get home. I’m surprised at how fast your blog loaded on my cell phone.. I’m not even using WIFI, just 3G. Anyways, awesome blog!
    python interview questions and answers
    python tutorials
    python course institute in electronic city

    ReplyDelete
  40. Thank For Sharing Your Information The Information Shared Is Very Valuable Please Keep Updating Us Time Went On Just Reading The Article Python Online Course

    ReplyDelete
  41. Hey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
    AWS Training in Chennai
    Data Science Training in Chennai
    Python Training in Chennai
    RPA Training in Chennai
    Digital Marketing Training in Chennai

    ReplyDelete
  42. This post is much helpful for us. This is really very massive value to all the readers and it will be the only reason for the post to get popular with great authority.
    Devops Training in Chennai | Devops Training Institute in Chennai

    ReplyDelete
  43. Thank you so much for posting this. I really appreciate your work. Keep it up. Great work!Best Placement company in Hyderabad

    ReplyDelete
  44. This post is really nice and pretty good maintained.
    Python Course in Chennai

    ReplyDelete
  45. Thanks For Sharing The Information The Information Shared Is Very Valuable Please Keep Updating Us Time Just Went On Reading The article Python Online Course Hadoop Online Course Aws Online Course Data Science Online Course

    ReplyDelete
  46. Well done! Your explanation way is very attractive for me and I like more tips from your great post. Surely I will share your great post for my friends and this is very useful for freshers. Keeping the great work!
    Oracle Training in Chennai
    Oracle Training institute in chennai
    Oracle DBA Training in Chennai
    Excel Training in Chennai
    Corporate Training in Chennai
    Tableau Training in Chennai
    Social Media Marketing Courses in Chennai
    Oracle Training in Chennai
    Oracle Training institute in chennai

    ReplyDelete
  47. Very well great blog post. This is a wonderful article, Given so much info in it, keep sharing.


    Data Science

    ReplyDelete
  48. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    date analytics certification training courses
    data science courses training
    data analytics certification courses in Bangalore
    ExcelR Data science courses in Bangalore

    ReplyDelete
  49. I read that Post and got it fine and informative. Please share more like that...
    Data Science Course in Pune

    ReplyDelete
  50. Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
    python training in bangalore

    ReplyDelete
  51. I really enjoyed reading this post, big fan. Keep up the good work andplease tell me when can you publish more articles or where can I read more on the subject?




    BIG DATA COURSE MALAYSIA

    ReplyDelete
  52. Thank you for sharing this Information.
    Check out the best
    furniture nz
    furniture sale
    Dog Cages

    ReplyDelete
  53. This is very good content you share on this blog. it's very informative and provide me future related information...
    Oracle DBA Online Training

    ReplyDelete
  54. You might comment on the order system of the blog. You should chat it's splendid. Your blog audit would swell up your visitors. I was very pleased to find this site.I wanted to thank you for this great read!!
    Data Science Courses

    ReplyDelete
  55. After reading your article I was amazed. I know that you explain it very well. And I hope that other Python classes in pune readers will also experience how I feel after reading your article.

    ReplyDelete
  56. This is a smart blog. I mean it. You have so much knowledge amazon web services training in Bangalore about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses.

    ReplyDelete
  57. I see the greatest contents on your blog and I extremely love reading ITIL certification them.

    ReplyDelete
  58. very nice article this is very useful blog.same time i got the information thanks for your blog web design company in velachery

    ReplyDelete
  59. Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
    If you are looking for any Data science Related information please visit our website best course for data science page!

    ReplyDelete
  60. Nice Post...I have learn some new information.thanks for sharing.
    Click here for ExcelR Business Analytics Course

    ReplyDelete
  61. Very nice post here and thanks for it .I always like and such a super contents of these post.
    web design company in chennai

    ReplyDelete
  62. Attend The PMP Certification From ExcelR. Practical PMP Certification Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The PMP Certification.
    ExcelR PMP Certification

    ReplyDelete
  63. This is an awesome blog. Really very informative and creative contents. This concept is a good way to enhance the knowledge. Thanks for sharing.
    ExcelR business analytics course

    ReplyDelete
  64. Lovely blog ..! I really enjoyed reading this article. Thank you for sharing such a wonderful post
    aws Training in Bangalore
    python Training in Bangalore
    hadoop Training in Bangalore
    angular js Training in Bangalore
    bigdata analytics Training in Bangalore.best oracle training in bangalore

    ReplyDelete
  65. The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. IEEE final year projects on machine learning In case you will succeed, you have to begin building machine learning projects in the near future.

    Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.


    Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.

    ReplyDelete
  66. Such a great information for blogger i am a professional blogger thanks…

    Looking for Best Training Institute in Bangalore , India. Softgen Infotech is the best one to offers 85+ computer training courses including IT Software Course in Bangalore , India. Also, it provides placement assistance service in Bangalore for IT.

    ReplyDelete
  67. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
    Cyber Security Projects for Final Year

    JavaScript Training in Chennai

    Project Centers in Chennai

    JavaScript Training in Chennai

    ReplyDelete
  68. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts.Prathima Infotech training center bangalore

    ReplyDelete
  69. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.Prathima Infotech training center bangalore

    ReplyDelete
  70. Awesome,Thank you so much for sharing such an awesome blog.Prathima Infotech training center bangalore

    ReplyDelete
  71. Thanks for sharing this blog. This very important and informative blog.Become a Trainer

    ReplyDelete
  72. Learned a lot of new things from your post! Good creation and HATS OFF to the creativity of your mind.Student Reviews

    ReplyDelete
  73. Thanks for sharing this blog. This very important and informative blog. content










    ReplyDelete
  74. Spot on with this write-up, I actually believe this website needs far more attention. I’ll probably be returning to see more, thanks for the
    information!

    ReplyDelete
  75. Nice blog,I understood the topic very clearly,And want to study more like this.
    Data Scientist Course

    ReplyDelete
  76. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.

    machine learning course

    artificial intelligence course in mumbai

    ReplyDelete
  77. Impressive! I finally found a great post here. Nice article on data science . It's really a nice experience to read your post. Thanks for sharing your innovative ideas to our vision.
    Data Science Course in Marathahalli

    ReplyDelete
  78. I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

    Digital marketing course mumbai

    ReplyDelete
  79. Attend The Course in Data Analytics From ExcelR. Practical Course in Data Analytics Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Course in Data Analytics.
    Course in Data Analytics
    Data Science Interview Questions

    ReplyDelete

  80. Inspirational Blog The Content Mentioned is Knowledgeable and Very Effective .Thanks For Sharing It

    AI Training In Hyderabad

    ReplyDelete
  81. Excellent Blog very imperative good content

    https://www.analyticspath.com/artificial-intelligence-training-in-hyderabad

    ReplyDelete
  82. Nice blog with excellent information. Thank you, keep sharing...
    dot net course in bangalore

    ReplyDelete
  83. Attend The Machine Learning course Bangalore From ExcelR. Practical Machine Learning course Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Machine Learning course Bangalore.
    Machine Learning course Bangalore

    ReplyDelete
  84. Nice blog with excellent information. Thank you, keep sharing...
    Oracle Training in Bangalore

    ReplyDelete
  85. The concept has been explained very well. Gained clear knowledge about the prominence of AWS
    AWS Training in Hyderabad

    ReplyDelete
  86. For me its lonelyness being left out not on purpose but not being included in all the things I cant do and not being able to drive. I can go on & on but the bottom line is its so hard to stay possitive and happy when nobodys there to share in your happiness its like having a contagous disease nobody wants to near it What a shame. Boy if I could redo my life. Thank you for reading and next time you want to put a smile on someones face just listen.Facts about Las Vegas

    ReplyDelete
  87. Attend The Data Science Courses From ExcelR. Practical Data Science Courses Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Science Courses.
    Data Science Courses
    Data Science Interview Questions

    ReplyDelete
  88. This is a very good post which I really learn this blog. I have the possibility to see something like this.
    Data Science Training In Hyderabad

    ReplyDelete
  89. Attend The Machine Learning course Bangalore From ExcelR. Practical Machine Learning course Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Machine Learning course Bangalore.
    Machine Learning course Bangalore

    ReplyDelete
  90. Thanks for sharing blog. The explanation of your articles is very good. It was very interesting and meaningful. I really appreciate it! Keep updating stuffs like this.
    Machine Learning Training In Hyderabad

    ReplyDelete
  91. wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
    Data science Interview Questions

    ReplyDelete
  92. wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
    Data science Interview Questions

    ReplyDelete
  93. Great blog created by you. I read your blog, its best and useful information. Super blogging and keep it updating
    Blockchain Training in Hyderabad

    ReplyDelete
  94. wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
    Data Science Course

    ReplyDelete
  95. Attend The Data Science Courses From ExcelR. Practical Data Science Courses Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Science Courses.
    Data Science Courses
    Data Science Interview Questions

    ReplyDelete
  96. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspried me to read more. keep it up.
    Correlation vs Covariance

    ReplyDelete
  97. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance

    ReplyDelete