Forum Discussion
HKosova
9 years agoSmartBear Alumni (Retired)
secloreqa wrote:
I am trying to add a validation point in my Test Script using the Content of File Document.
So,for making sure the file has opened successfully, I want to check the content of the file against the base initial Text
There's an extension for TestComplete to compare Word files; you can download it here:
http://support.smartbear.com/viewarticle/17635/
Copy this extension to <TestComplete>\Bin\Extensions\ScriptExtensions, and then you can use this code:
WordDocs.Compare(file1path, file2path, 1);
For details and parameters, see this article: Compare Word files.
If you need just to read a Word file (and not compare 2 files), you can use the Word COM object, Word.Application. Here's an example:
// JScript
// Open a file in Word var oWord = Sys.OleObject("Word.Application"); oWord.Visible = true; var oDoc = oWord.Documents.Open("C:\\Test.doc"); // Read the paragraphs one by one, and post them to the log for (var i = 1; i <= oDoc.Paragraphs.Count; i++) { Log.Message(oDoc.Paragraphs.Item(i).Range.Text); } oDoc.Close();
Related Content
- 5 years agoLeela1
- 11 months agoKimdoengart
- 2 years agoTaz
Recent Discussions
- 3 days agoMW_Didata