LOGGING INTO THE GMAIL APPLICATION USING COM (WITHOUT USING ANY AUTOMATION TOOL)


‘Below is the example for logging into the Gmail Application using COM (without using any automation tool)
Public objIE, objPage

'Launching Web Application
funcLaunchWebApp()

'Verifying for Launching the Application
funcPageSync(objIE)

'Creating Document Object
Set objPage = objIE.Document

'Set User Name for GMail Login Page
funcSetValueForEditBox objPage, "Email", "rama"

'Set Password for GMail Login Page
funcSetValueForEditBox objPage, "Passwd", "krishna"

'Click on Sing In Button
funcButtonClick objPage, "Sign in"

'Function for Click in Button
Function funcButtonClick(objPage, strButtonToClick)

                'Get Objects from Specific Page with TagName Input
                Set objButtons = objPage.GetElementsByTagName("INPUT")

                'Click on Specific Button
                For Each objButton in objButtons
               
                                If LCase(objButton.Type) = "button" or LCase(objButton.Type) = "submit" Then

                                                If LCase (objButton.Value) = LCase(strButtonToClick) then

                                                                objButton.Click

                                                                boolButtonClicked = true

                                                End If

                                End If

                Next

End Function

'Function for Setting Value for Specific Edit Box
Function funcSetValueForEditBox(objPage, strEditBoxName, strEditBoxValueToSet)


                Set objEditBoxes = objPage.GetElementsByTagName("Input")

                For Each objEditBox in objEditBoxes


                                If LCase(objEditBox.Name)=LCase(strEditBoxName) and LCase(objEditBox.Type) = "text" Then


                                                objEditBox.Value = strEditBoxValueToSet

                                                Exit For

                                ElseIf LCase(objEditBox.Name)=LCase(strEditBoxName) and LCase(objEditBox.Type) = "password" Then


                                                objEditBox.Value = strEditBoxValueToSet

                                                Exit For

                                End If

                Next


End Function


'Function for Launching Web Application
Function funcLaunchWebApp()

                Set objIE=CreateObject("internetexplorer.application")
                objIE.Visible=True
                objIE.Navigate "www.gmail.com"

End Function

'Function for Verifying Launching the Application
Function funcPageSync(objIE)

                For intWait = 1 to 60

                                If objIE.ReadyState = 4 Then
                                                Exit For
                                                WScript.Echo "Goolge Search Page Launched Successfully"

                                Else

                                                WScript.Sleep 1000
                                End IF
                Next

End Function