Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Browser("Google").link("Advanced Search").click
Posted by Hari Sreekanth Upadrasta at 8:27 AM 2 comments
Recently i was working on a project where i have been using Dictionary object a lot. In a function i had to retrieve the number of Items that i have added to the Dictionary. But to my utter dismay I found that the number of items in the dictionary turned out to be two more than the items actually added to it. So I tried to find out of how did that happened, when I was not able to, I googled a lot (thinking that dictionary objects may be collecting some garbage value)but found nothing that could satisfy me. So I just left it there. The other day I started working on other things where I had to add some variables to debug viewer and verify their values in runtime. After the second run of the test I found that the values of the variables that I added to the debug viewer are having value as EMPTY. Then I realized the real culprit for making me and my dictionary object go bonkers is THE DEBUG VIEWER How did this happen: I entered two dictionary items in to the debug viewer for which the keys are non existent. And the next time I ran my script, the items got initialized to empty (Dictionary can take Empty values). So as a victim of the Debug Viewer I just want to tell you a few things. Points that should be kept in mind while using debugger while debugging Remove all the items from the debug viewer after debugging. QTP can hang if you have placed exist statement in the debug viewer and start your script. QTP can be very slow if you debug your scripts with lot of Exist statements in it(debug viewer). And Finally dont do the mistake I have done(Dictionary can take Empty values)
have been working on some issues Recently.In the process i came to know that vba is somewhat superior to vbscript in Test Automation scripts development(Check thislink).So i started creating a function library in vba for use in vbscript and succeded upto an extent.
So finally i broke the shackles and started posting in my blog.I Here is my procedure:
There are lots of Advantages of using a vba function library in qtp/vbscript which will be mentioned in my next post until then happy scripting.
Posted by Hari Sreekanth Upadrasta at 3:56 AM 1 comments Labels: MODULE, QTP, VBA, VBscript
Finally i think i have done what i have thought of doing from long time. This has been bugging me from a long time.Now we can convert almost any DATE/TIME format to any required DATE/TIME format. Suppose you want to convert 12,jan 2008 to january,08-12. you can just do that as simple as this: reformat = DTFormat("12,jan 2008","MMMM,YY-DD") Procedure:
1. 2. 3. 4. 5.
Download the Zip File DTFormat to your QTP's Bin folder(or any where you want). Unzip it (The folder contains three files DTFormat.dll , DTFormat.vbs and DTFormat.Doc). Double click on DTFormat.vbs file. Enter the name with which you want to use this functionality in QTP. Click OK button.
This is very powerful indeed Read the Document in the zip file to know the power of it. This is also a powerful time converter as well. regards,
Posted by Hari Sreekanth Upadrasta at 5:34 AM 0 comments
Today i had a weird situation.i had to enter my password in a driver script before my project mates and my manager, to show them a demo of how it works.The situation is so weird that i can't ask them to turn to the other side nor was i capable of entering passwords faster(i have to enter password in a inputbox). So, i thought of exploring it a bit and did some Google search and got some piece of code it uses the property of the password element of the HTML. Here is the code: <SCRIPT LANGUAGE="VBScript"> Sub RunScript OKClicked.Value = "OK" End Sub Sub CancelScript OKClicked.Value = "Cancelled" End Sub </SCRIPT> <BODY> <font size="2" face="Arial"> Password: </font><font face="Arial"> <input type="password" name="UserPassword" size="40"></font></p> <input type="hidden" name="OKClicked" size = "20"> <input id=runbutton class="button" type="button" value=" OK "
name="ok_button" onClick="RunScript"> <input id=runbutton class="button" type="button" value="Cancel" name="cancel_button" onClick="CancelScript"> </BODY> Copy the code and paste it in note pad and save it in your C drive as "Password.htm" Now open another notepad, paste the code below and save it as Password.vbs Set objExplorer = WScript.CreateObject _ ("InternetExplorer.Application", "IE_") objExplorer.Navigate "file:///C:\Scripts\password.htm" objExplorer.ToolBar = 0 objExplorer.StatusBar = 0 objExplorer.Width = 400 objExplorer.Height = 350 objExplorer.Left = 300 objExplorer.Top = 200 objExplorer.Visible = 1 Do While (objExplorer.Document.Body.All.OKClicked.Value = "") Wscript.Sleep 250 Loop strPassword = objExplorer.Document.Body.All.UserPassword.Value strButton = objExplorer.Document.Body.All.OKClicked.Value objExplorer.Quit Wscript.Sleep 250 If strButton = "Cancelled" Then Wscript.Quit End If 'Now you can use the entered password msgbox strPassword Now double click on the Password.vbs file Remember there are other ways of doing it even more effectively but this is the most robust way(it works independent of O/S). Regards,
Posted by Hari Sreekanth Upadrasta at 4:03 AM 2 comments Labels: HTML, Mask Password, QTP
Hi, We have seen in my previous post on howto send email no lets look at how to verify them. olFolderInbox = 6 varSubject = "Test Mail" 'The subject of your mail Set objOutlook = CreateObject("outlook.application") Set objNameSpace = objOutlook.GetNameSpace("MAPI") Set Inbox = objNameSpace.GetDefaultFolder(olFolderInbox) Set Mail = Inbox.Items.Restrict("[Subject] = " & Chr(34) & varSubject & Chr(34) ) 'The above line is used to filter mails by subject similarly u can use "From" in place of subject. if Mail.Count = 1 then Msgbox "Mail Found" Else Msgbox "Mail Not present or there are More than one mail with same subject" End if Thats it for now .
Posted by Hari Sreekanth Upadrasta at 1:24 AM 5 comments Labels: Mail, MAPI, Outlook, Outlook Automation, QTP
And click on Options button. The following window opens. Navigate to Scripting tab and select "Enable scripting" checkbox and deselect the other two options below the "Enable scripting" checkbox.This complets enabling clientside scripting. Serverside Setting:Run the transaction code RZ11 ,this opens Maintain Profile Parameters page entersapgui/user_scripting and click on Display button.
this opens
check if Profileval is set to TRUE else click on change value button and change the value of profileval to TRUE. This completes our Enable scripting process.
Posted by Hari Sreekanth Upadrasta at 2:52 AM 0 comments Labels: Client side, QTP, SAPI, Server side
API(Application Programming Interface): An API is a guide(remember it is just a guide) which keeps in it all the constants , objects and the object's methods and parameters with which the application or the application's features can be used in another program. EX: Most of you might have came across QTP automation object model documentation this is QTP's automation API. Another EX: Speech API(SAPI) is an API developed by Microsoft to allow the use of speech recognition and speech synthesis within Windows applications(Office).Here the Office applications are using the SAPI. In the same way if your manager comes to you and asks you to make your script speak once your test is completed. try the following lines in your QTP or VBscript editor and run it: '********************************************************************************** Dim voice Set voice = CreateObject("SAPI.SpVoice") voice.speak "Yahoooo, it is working" '********************************************************************************** If you get a chance to look at the SAPI you will find that SpVoice is the object and speak is the method