Jump to content

Autologin with selecting options + Click button


Recommended Posts

Hello!

Im trying to do a script, where he open the website IE, use my username, password and select an option. but i can understand how select the option and click on button.

Can someone help plz?

i do this:

#NoTrayIcon
#include <IE.au3>

Local $oIE =_IECreate("www.segurnet.pt")
_IELoadWait($oIE)


$Name = _IEGetObjByName($oIE, "username")
$Password = _IEGetObjByName($oIE, "j_password")
_IEPropertySet ($Name, 'innerText', 'test')
_IEPropertySet ($Password, 'innerText', 'test12345')

; need select the option 

;need click button to login.


While 1
  Sleep(10000)
  _IEAction($oIE, 'refresh')

WEnd

 

 

Link to comment
Share on other sites

Hi @Reyzor:)
What about this? :)
 

#include <IE.au3>

Global $strURL = "https://www.segurnet.pt/", _
       $objIE, _
       $objUsername, _
       $objPassword, _
       $objComboBox, _
       $objButton


$objIE = _IECreate($strURL, 0, 1)
If @error Then
    ConsoleWrite("Errore while creating the IE object. Error: " & @error & @CRLF)
Else
    $objUsername = _IEGetObjById($objIE, "username")
    If @error Then
        ConsoleWrite("Error while obtaining the Username object field. Error: " & @error & @CRLF)
    Else
        _IEDocInsertText($objUsername, "Username")
        If @error Then
            ConsoleWrite("Error while typing the Username. Error: " & @error & @CRLF)
        Else
            $objPassword = _IEGetObjById($objIE, "j_password")
            If @error Then
                ConsoleWrite("Error while obtaining the Password object field. Error: " & @error & @CRLF)
            Else
                _IEDocInsertText($objPassword, "Password")
                If @error Then
                    ConsoleWrite("Error while typing the Password. Error: " & @error & @CRLF)
                Else
                    $objComboBox = _IEGetObjById($objIE, "company")
                    If @error Then
                        ConsoleWrite("Error while obtaining the Company object ComboBox. Error: " & @error & @CRLF)
                    Else
                        ; This allows you to select an option from a Select element, thanks to the text of an option of the Select element
                        _IEFormElementOptionSelect($objComboBox, "Victoria Seguros", 1, "byText")
                        If @error Then
                            ConsoleWrite("Error: " & @error & @CRLF)
                        Else
                            $objButton = _IEGetObjById($objIE, "signin")
                            If @error Then
                                ConsoleWrite("Error while obtaining the Button object. Error: " & @error & @CRLF)
                            Else
                                ; Do stuffs...
                                ; _IEQuit($objIE)
                            EndIf

                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
EndIf

Using _IEFormElementOptionSelect() function, you can select and option from you Select element, even if it is not in a Form :)
 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...