This tip is about integrating a free tool’s capability by using wsh/vbscript as an interactor. VBScript as an Interactor with other free tools to automate any website or desktop application. I have been using this method to automate some of my testing tasks since a long time. What I usually do is I just create script to initiate the automation of a task, which includes opening and adding actions to other tools to complete the automation. I also try to enhance the script which will fit for many other applications. Objective Integrate other free tools capability by VBScript as an interactor to automate any task for testing websites or Desktop applications. The script, I have created is very simple VBScript which can be understood by even a beginner to VBScript. In the script, general functions like run, sendkeys, sleep and some loops are used. I generally avoid using specific application object and call methods for that object like if I want some work from Excel, then prefer to do it by doing sendkeys rather than creating an object as Excel.application. But it also can be used to enhance the ability of the script. The benefit in my script I found is that if you know any application which can help you to automate something then you can use it without knowing about its method’s name for the object of that application in VBScript . I believe it will help beginners to automate anything using VBScript . Let us see a script for login screen. The login screen must have only two input fields as the script is written only for websites having two input fields in the login page. If there are more than two input fields then we need to change the script little or need to put specific search with conditions to find specific text fields and put data for login In this script I have used IE as the default Browser and Developer Tools to find the textboxes or input fields. Copy and paste it in notepad and save it as *.vbs Just need to change the URL in the script to check other sites, In this script the url is fixed, if the script is not working then increase the sleep time. |
Copy and save it as *.vbs. Required – Default browser IE and Developer tool should be enabled. Automate SQL injection or security testing, Change the Input data as per requirement. Modify it as per your requirement. Script :- |
Dim obj Set obj = CreateObject("wscript.shell") obj.run ("http://thedemosite.co.uk/login.php") WScript.Sleep 3000 obj.SendKeys("{F12}") WScript.Sleep 500 obj.SendKeys("%e") 'it is just activating edit and below deactivating it. WScript.Sleep 100 obj.SendKeys("%e") 'here it Is deactivating the edit, I need To Do it because i found that in Value="" 'Is already exist Then, 'it Is Not adding the value again, so activating and deactivating the edit, 'it is deleting the value="" 'attribute. we also can add value by using Attribute tab in the right column. 'if there is no value="" 'then it is easy to add just by sending keys ctrl + =. WScript.Sleep 200 obj.SendKeys("^e") 'Navigating to search field of developer tool. WScript.Sleep 200 obj.SendKeys("^a{delete}