How to open a file in one script and write into it in another script - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: How to open a file in one script and write into it in another script (/Thread-How-to-open-a-file-in-one-script-and-write-into-it-in-another-script) |
How to open a file in one script and write into it in another script - reejais - 10-01-2010 Hi All, Can anybody tell me how to open a file in one script and write into it in a different script? I have to open a file once in login script and use it in all the test cases script to write the result of the test case into it. I have written a code like this in login script Code: Dim fso Code: tf.writeline("Pass") But this doesn't work. RE: How to open a file in one script and write into it in another script - cdesserich - 10-02-2010 Just curious, why can't you just reopen the file in the next script? This approach would also have the advantage of being able to open the file in "append" mode so that you aren't accidentally writing over your previous results: Script 1 Wrote:'Script 1 (Login script?) Script 2 Wrote:'Script 2 If you are talking about a test that calls reusable actions and you want to be able to hand the text file between the actions, you could use an environment variable. This works as long as the scripts are calling each other (i.e. clicking run once) since the environment variable only lives for the current test run: Quote:'Store the text file object in a varaible --> RE: How to open a file in one script and write into it in another script - reejais - 10-05-2010 Thanks for the reply. Yes I wanted to create a file in one script and use it all the other scripts for appending. RE: How to open a file in one script and write into it in another script - cdesserich - 10-05-2010 So have you tried one of the strategies from my first post? RE: How to open a file in one script and write into it in another script - bfakruddin - 10-05-2010 Hi, I've developed some code here. I' working on RFT now... If any syntax's mixed with java, Plz ignore and convert into VBScript. I'm writing this with out using QTP. just I analyzed and developed... check it once and revert me if you get any issues with this. Here, you can first create a text file at your desired location and then pass the values required to the function. just call this function and conclude that the passing text has been appended to file. Code: public function fncAppendFile(path_of_the_file, updating_text_into_file) Baba Fakruddin.D RE: How to open a file in one script and write into it in another script - reejais - 10-08-2010 Hi All, Thanks for the reply. @cdesserich, The environment variable still not works and displays an error "Object not found in the OR" in the script where I am using tf.writeline. But my issue is resolved for now though I have not tried different ways. This is what I do now. Currently I am using my library file to open the Result.txt file and I am declaring the "tf" variable as Public and attaching the library file with my script and this works fine now. @Baba, later I am going to try out the script which you have given too. Regards, Reema. |