Jump to content
Sign in to follow this  
michaelslamet

FF.AU3: can not automate login on this site

Recommended Posts

michaelslamet

I'm trying to automate login on this site in the last few days, and I have to admit it drive me crazy.

Seems like there is no solution.

The site is rumah123 dot com

Click on the "Login atau Daftar" link at top right screen.

(I am using this code that work beautifully to click on that link):

$oInput = _FFXPath('//*[@data-target="#LoginAgentModal"]')
Sleep(250)
_FFDispatchEvent($oInput, 'keypress', 13)

A login form will displayed.

The problem no matter what code I tried, it can not fill the "username" and "password" part.

Tried these without success:

_FFXPath('//input[@id="username"]')
_FFCmd("FFau3.xpath.value='me@me.com'")
_FFSetValue("me@me.com", "username", "id")
_FFSetValue("$me@me.com", "username", "name")

Tried also with SEND command, but the SEND command is very not reliable: sometime it works, sometime not:

BlockInput(1)
Sleep(500)
WinActivate("[CLASS:MozillaWindowClass]", "")
Sleep(50)
For $a = 1 to 5
    Sleep(50)
    Send("{TAB}")
Next
Sleep(50)
Send($Username[1])
Sleep(50)
Send("{TAB}")
Sleep(50)
Send($Password[1])
Sleep(50)
Send("{TAB}")
Sleep(50)
Send("{SPACE}")
BlockInput(0)

Is there is any way to automate this kind of form/site using FF.AU3 ?

Thanks a lot! :)

 

Share this post


Link to post
Share on other sites
Danp2
Tried these without success: 


_FFXPath('//input[@id="username"]')
_FFCmd("FFau3.xpath.value='me@me.com'")

This works for me. Telling us that it didn't work isn't helpful. Examine / post the results from the Scite output window if you want to make progress on this. ;-)

Share this post


Link to post
Share on other sites
michaelslamet
8 hours ago, Danp2 said:
Tried these without success: 


_FFXPath('//input[@id="username"]')
_FFCmd("FFau3.xpath.value='me@me.com'")

This works for me. Telling us that it didn't work isn't helpful. Examine / post the results from the Scite output window if you want to make progress on this. ;-)

Thanks a lot Danp2, for trying to help :)

This is the output of the Scite:

_FFConnect: OS: WIN_XP WIN32_NT 2600 Service Pack 3
_FFConnect: AutoIt: 3.3.8.1
_FFConnect: FF.au3: 0.6.0.1b-15
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     1276
_FFConnect: Browser:    Mozilla/5.0 (Windows NT 5.1; rv:43.0) Gecko/20100101 Firefox/43.0
__FFSendJavaScripts: Sending functions to FireFox .......... done
_FFLoadWait: ... loaded in 543ms
[object HTMLDocument] - {location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, writeln: function() {...}, ...}
_FFLoadWait: . loaded in 11ms
[object HTMLDocument] - {location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, writeln: function() {...}, ...}
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//*[@data-target='#LoginAgentModal']",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: http://www.rumah123.com/modals/login - {toString: function() {...}, target: "", download: "", ping: "", rel: "nofollow", relList: {...}, hreflang: "", ...}
__FFSend: try{FFau3.simulateEvent(FFau3.xpath,'KeyboardEvent','keypress',13);}catch(e){'_FFCmd_Err';};
__FFRecv: 1
__FFSend: FFau3.WCD=window.content.top.document;
__FFRecv: [object HTMLDocument] - {location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, writeln: function() {...}, ...}
[object HTMLDocument] - {location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, writeln: function() {...}, ...}
__FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//input[@id='username']",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;}catch(e){'_FFXPath_Error: '+e;};
__FFRecv: 
__FFSend: try{FFau3.xpath.value='me@me.com'}catch(e){'_FFCmd_Err';};
__FFRecv: _FFCmd_Err
_FFLoadWait: . loaded in 11ms
[object HTMLDocument] - {location: {...}, getElementsByName: function() {...}, getItems: function() {...}, open: function() {...}, close: function() {...}, write: function() {...}, writeln: function() {...}, ...}
+>12:56:22 AutoIT3.exe ended.rc:0
>Exit code: 0    Time: 12.776

Tried with FF.au3 version 10 and 15, both dont work in this case.

Currently I'm using _WinAPI_Keybd_Event to simulate the TAB key. Works much better than SEND, but not 100% success. If it possible, I prefer using FF.AU3 function to do this task.

This the _WinAPI_Keybd_Event code that working much better than SEND:

BlockInput(1)
Sleep(250)
WinActivate("[CLASS:MozillaWindowClass]", "")
; press TAB 5 times
For $a = 1 to 5
    _WinAPI_Keybd_Event ( 0x09, $KEYEVENTF_EXTENDEDKEY)
    _WinAPI_Keybd_Event ( 0x09, $KEYEVENTF_KEYUP)
    Sleep(200)
Next
Send($Username[1])
_WinAPI_Keybd_Event ( 0x09, $KEYEVENTF_EXTENDEDKEY)
_WinAPI_Keybd_Event ( 0x09, $KEYEVENTF_KEYUP)
Sleep(200)
Send($Password[1])
; press TAB 2 times
_WinAPI_Keybd_Event ( 0x09, $KEYEVENTF_EXTENDEDKEY)
_WinAPI_Keybd_Event ( 0x09, $KEYEVENTF_KEYUP)
Sleep(200)
_WinAPI_Keybd_Event ( 0x09, $KEYEVENTF_EXTENDEDKEY)
_WinAPI_Keybd_Event ( 0x09, $KEYEVENTF_KEYUP)
Sleep(200)
; press SPACE to login
_WinAPI_Keybd_Event ( 0x20, $KEYEVENTF_EXTENDEDKEY)
_WinAPI_Keybd_Event ( 0x20, $KEYEVENTF_KEYUP)
Sleep(200)
BlockInput(0)

Wonder why it works on your side but not on mine?

Share this post


Link to post
Share on other sites
Danp2

The trick is that you have to wait until the elements are visible. This works for me:

#include <FF.au3>

If _FFConnect() Then
    _FFTabAdd('rumah123.com')

    $oInput = _FFXPath('//*[@data-target="#LoginAgentModal"]')
    _FFCmd('FFau3.xpath.click()')

    While True
        _FFXPath('//input[@id="username"]')
        $result = _FFCmd('FFau3.xpath')

        If $result <> '' Then
            ExitLoop
        EndIf
    WEnd

    $cValue = 'me@me.com'
    $result = _FFCmd("FFau3.xpath.value='" & $cValue & "'")
EndIf

 

  • Like 1

Share this post


Link to post
Share on other sites
michaelslamet
On 2/6/2016 at 11:19 PM, Danp2 said:

The trick is that you have to wait until the elements are visible. This works for me:

#include <FF.au3>

If _FFConnect() Then
    _FFTabAdd('rumah123.com')

    $oInput = _FFXPath('//*[@data-target="#LoginAgentModal"]')
    _FFCmd('FFau3.xpath.click()')

    While True
        _FFXPath('//input[@id="username"]')
        $result = _FFCmd('FFau3.xpath')

        If $result <> '' Then
            ExitLoop
        EndIf
    WEnd

    $cValue = 'me@me.com'
    $result = _FFCmd("FFau3.xpath.value='" & $cValue & "'")
EndIf

 

Perfect! Thank  you, Danp2! :)

Share this post


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
Sign in to follow this  

  • Similar Content

    • MakzNovice
      By MakzNovice
      Hello Experts,
      I am working on modifying table data of a browser currently in IE (soon in FF)
      My sequence of operations:
      1. Activate Browser
      2. Get Browser table
      3. Modify data  in table
      4. Suppress any warning/error message from webpage
      5. Activate the Webpage again 
      6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5})
       
      My problem is at Step 5, as it activates the wrong window ( last used application rather than my browser window)
      My code snippet for it as follows
      $bFoundWindow = False Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]") Local $hWND = 0 For $i = 1 To $aList[0][0] If False = $bFoundWindow And $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 1) Then WinActivate($aList[$i][1]) ; 1. Activate Browser window WinSetState ( $aList[$i][1], "", @SW_MAXIMIZE) $hWND = $aList[$i][1] $objEditIE = _IEAttach ($aList[$i][1], "hwnd") $oTitles = _IETagNameGetCollection($objEditIE, "TITLE") For $oTitle In $oTitles $sTitle = $oTitle.innerText If $sTitle = $searchString Then MsgBox(0,"APPLICATION Found", "Got Edit List Window", 1) $bFoundWindow = True ExitLoop EndIf Next EndIf Next If False = $bFoundWindow Then MsgBox(0,"Error","Please launch Edit window for updating values in Browser prior to script execution",10) Exit EndIf ; MY CODE HERE TO MODIFY TABLE ; 2. Get Browser table ; 3. Modify data  in table ; Check if message from webpage pop-up window exists if so click ok on it Local $nCounter = 0 Local $nMaxCounter = 5 while 1 If WinExists("Message from webpage","") Then ControlClick("Message from webpage","","Button1","primary",1) ;4. Suppress any warning/error message from webpage Else $nCounter = $nCounter + 1 Sleep(100) ;MsgBox(0,"Counter", $nCounter, 1) If $nCounter = $nMaxCounter Then ExitLoop EndIf WEnd ;5. Activate the Webpage again  WinActivate($hWND) ; have already tried WinActivate($aList[$i][1]) but no success ;6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5}) Send("{F11}") WinActivate($hWND) ;WinActivate($aList[$i][1]) Sleep(100) Send("{F11}") Any support will be highly appreciated
    • MakzNovice
      By MakzNovice
      I am using FF.au3, Since its proprietary I can't share image or link for the data I am using.
      But here is my problem abstract code .
      ; Test if I get table contents correctly
      ;$sCurr= _FFXPath("/html/body/form[1]/div[2]/div[3]/div[2]/table[@id='bodyTable']/tbody/tr[3]/td[4]", "textContent")
      ;MsgBox(0, "Current Value ", $sCurr, 2) ; output " -254.4"
      $sObj = _FFXPath("/html/body/form[1]/div[2]/div[3]/div[2]/table[@id='bodyTable']/tbody/tr[3]/td[4]")
      MsgBox(0, "Object", $sObj, 2) ; output "OBJECT|FFau3.xpath"
      $sRet = _FFObj($sObj, "value", "-253.4")
      MsgBox(0, "Return Value", $sRet); output " -253.4"
      $s = _FFXPath("/html/body/form[1]/div[2]/div[3]/div[2]/table[@id='bodyTable']/tbody/tr[3]/td[4]", "textContent")
      MsgBox(0, "New Value", $s); output " -254.4"
      My expectation is that that last MsgBox shows new value that I had set that is "-253.4"
      I would highly appreciate any support on this
       
    • rudi
      By rudi
      Hello,
      usually I do Win automations, so I have no skills at all to handle HTML forms :-/
      The script to catch and syntax check  the required information from Excel is done.
      Now I'd like to automate the upload using this form, too:
       
      http://flashcardsdeluxe.com/flashcards/Upload.aspx
      What browser is easiest to do so? (IE, Chrome, FF) The Values $DeckCode, $DeckName, $DeckDefinition shall go to their HTML form fields finally "click" the button "upload flashcards" <table width="70%" class="cssCenter" border="0"> <tr> <td style="width: 1%">Deck&nbsp;Code</td> <td style="width: 100%"><input name="ctlDeckCode" type="text" id="ctlDeckCode" style="width:50%;" /> (no spaces allowed)</td> <td></td> </tr> <tr> <td style="width: 1%">Deck&nbsp;Name</td> <td style="width: 100%"><input name="ctlDeckName" type="text" id="ctlDeckName" style="width:50%;" /> (optional)</td> <td style="width: 1%" align="right"><input type="submit" name="ctlUpload" value="Upload Flashcards" id="ctlUpload" /></td> </tr> <tr> <td valign="top" style="padding-top: 5px" >Flashcard&nbsp;Text</td> <td colspan="2"><textarea name="ctlFlashcardText" rows="2" cols="20" id="ctlFlashcardText" style="height:280px;width:100%;"></textarea></td> </tr> </table> If someone kindly could jump in showing how to address just one of the input fields and how to "click" the "upload flashcards" button, I should be able to do the rest myself.
      TIA, Rudi.

    • Faraz
      By Faraz
      I have to open a URL on Mozilla Firefox , cursor is by default userid textbox, had to send userid, send tab, send pwd with flag 1 , send tab, send Enter.
      But Script is Failing to take Password.
      Any Help
       
      #include <Constants.au3>
      #include <IE.au3>
      #include <PassMask.au3>
      If $CmdLine[0] <> 3 Then
          MsgBox($MB_OK, "Usage", "ps_weblogin_FireFox <Url> <Browser Title> <Text to Send>")
      Else
         web_login($CmdLine[1], $CmdLine[2], $CmdLine[3])
      EndIf
      Func web_login($bt_url, $bt_Title, $bt_SendText)
          Local $ff = Run("C:\Program Files (x86)\Mozilla Firefox\firefox.exe " & $bt_url)
              WinWaitActive($bt_Title)
          Sleep(2000)
          ControlSend("","","",$bt_SendText)
      EndFunc
      _______________________________________________
      _______________________________________________
      Func Mask_Password($Password)
          $MaskPassword = $Password
          $MaskPassword = StringReplace($MaskPassword, "#", "||||||#@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "!", "||||||!@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "+", "||||||+@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "^", "||||||^@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "{", "||||||{@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "}", "||||||}@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "||||||", "{")
          $MaskPassword = StringReplace($MaskPassword, "@@@@@@", "}")
          Return $MaskPassword
      EndFunc
    • Marc
      By Marc
      Profiler - yet another backup script for Firefox and Thunderbird profiles
      It automatically detects the last recently used profile directories of Firefox and Thunderbird (installed versions, no portables).
      Clicking the Backup-Button creates a complete Backup of the found profiles with a timestamp.
      Restore deletes the according profile dir and extracts the content of the selected archive into the profile directory.
      Uses Winrar as compression tool, but feel free to change it to your needs
      Best regards
      Marc

      Profiler.au3
×