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 post
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 post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By singh54
      Hello All,

      I am new to auto It  and coding. Have only tried few automated logging for different websites.  The login pages of the websites which I have worked on were having form name with input type as text and it seems straight forward to automate their login using "_IEFormElementSetValue".
      I have got a url, it does not have any form in the source page. On further analyzing I found that It does call some login page separately as below.
      function showLogin(arg) {
        Global.pollingDialogDoc = null;
        var fresh = jQuery.isValidString(arg) && "fresh" == arg ? !0 : !1, appFrame = $("#appFrame");
        if ($("#modalFrame").show(), $("iframe").hide(), fresh || !appFrame.attr('src').match("html/login.html")) appFrame.attr('src', baseURL + 'html/login.html'), 
        appFrame.on('load', function() {
          setTimeout(function() {
            $("#modalFrame").hide(), appFrame.show();
          }, 1);
        }); else try {
          window.frames.appFrame.updatePageFromIndex();
        } catch (e) {}
      }
      I can simply use "send" and "mouse click" Method to automate the login but that doesn't seems very reliable. Is there any separate way to fill the user ID and password to the respective fields by having reference by frames or something. 
      Appreciate if any one can point me to correct document or help in any way...!
×
×
  • Create New...