At times we need to check spelling of multiple objects, such as Link, Button, Weblist etc present on a single page. In QTP,if we use the Record/Playback funtionality or the Shared Object Repository method, it would become difficult as we have to add all the onjects first and then do the spell check individually. To overcome this we can use descriptive programming and VB Script which will not only make the process short, it would also not require us to add the objects.
Here I am taking the Link object as an example, we can use any other object in the same way.
Set M_Word=CreateObject(“Word.Application”) ‘Creating the Word object
Set Desc=Description.Create `Creating the properties collection object
Desc(“micclass”).value=”Link” `Entering Properties information into object
Set Total_Links=Browser(” ”).Page(“ ”).ChildObjects(Desc) ‘collecting all the link objects present on page
For (i=0 to Total_Links.count-1)
M_Word.WordBasic.filenew ‘To open new word basic file
Link_Name=Total_Link(i).GetROProperty(“name”) ‘Taking the name property of every individual object
M_Word.WordBasic.insert Link_Name ‘To insert the Link Name
if M_Word.ActiveDocument.Spellingerrors.count>0 then
Reporter.Reportevent micPass, “Spelling”,”Spelling Error :”&Link_Name ‘To report the spelling mistake