Sign in to follow this  
Followers 0
michaelslamet

FF.AU3: can not automate login on this site

5 posts in this topic

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



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
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

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

 

1 person likes this

Share this post


Link to post
Share on other sites
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  
Followers 0

  • Similar Content

    • BOUNCER
      By BOUNCER
      I'm trying to get the output data from https://www.guilded.gg but it uses a web app that generates that output on the fly and this doesn't show up in the page source.
      Only in web inspector of each browser does this data show up. How do I read this data in autoit (equivalent to the web inspector)
       
      thank you
    • Pao
      By Pao
      Hello, I've recently updated from Firefox 50 to 54.0.1.
      My Autoit script that previously worked fine, now seems to have erratic problems.
      It's almost as if some Send() commands are sometimes skipped when dealing with the Firefox UI (it's still mostly fine on the actual pages).

      To temporarly fix the problem, I had to put some Sleep(200) pauses and avoid grouping keys together (e.g: TAB 2), but I'm not exactly sure about the correct way to deal with this..
      Could this be caused by the new multiprocess feature? (e10s)
      Are there better Autoit commands or rules that I should use?
       
    • rte7
      By rte7
      Hello. We work with the BMC Remedy site to manage incidents and would like to automate the processes of clicking through this button code:
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a> I use firefox with mozrepl and autoit with include FF.au3
      I need your help
      I read the topic https://www.autoitscript.com/forum/topic/95595-ffau3-v0601b-10/ but I could not run the code from the listed commands
      ...
      It is necessary to press the button and from the list of the menu of cahorsations to select the item = "zone of trust abonent"
      Screen # 1 http://joxi.ru/52aJK7bh4a7ypA or below.
      1) Press button
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a>
      2) After pressing the button, I need to choose in this menu of 4 items to select an item called "zone of trust abonent", Screen # 2 - http://joxi.ru/p27gwQKHo71VQ2
      html code table items
      <table class="MenuTable" cellpadding="0" cellspacing="0" style="width: 179px;"> <tbody class="MenuTableBody"> <tr class="MenuTableRow"> <td class="MenuEntryName" nowrap="">zone of trust abonent</td> <td class="MenuEntryNoSub" arvalue="zone of trust abonent"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust operator"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust third operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust third operator"></td></tr> <tr class="MenuTableRow"><td class="MenuEntryNameHover" nowrap="">No settings</td> <td class="MenuEntryNoSubHover" arvalue="No settings"></td> </tr> </tbody> </table>
       
       
      More in detail, I choose from the menu item "zone of trust abonent" Screen # 3 - http://joxi.ru/GrqVq4ZIQEPW4m

       
      3) The choice is made, Screen # 4 http://joxi.ru/v297w6aC3PovLr
      <textarea class="text sr " wrap="off" id="arid_WIN_0_1000002488" cols="20" maxlen="60" style="top:21; left:0; width:179; height:21;" armenu="CFG:PRC:CategoryHPD-Res-T1-Q" mstyle="2" arautoc="1" arautocmb="1" arautocak="0" arautoctt="400" rows="1"> </textarea>
       
      It's all. I would be very grateful to you =) !!!!!!!!!!
      Here are more detailed codes in the attachment. 
      button1.txt
      menu - table.txt
      all.txt
    • milos83
      By milos83
      How can I check if element is focused in Firefox using FF.au3 UDF?
      This is my try:
      I have prepared a function that checks if the object is focused:
       
      _FFCmd('FFau3.isfocused=function isfocused(a){try{return (a === document.activeElement)}catch(e){return}}') $oElm = _FFXPath("//*[@id='someId']") ConsoleWrite(_FFIsFocused($oElm)) Func _FFIsFocused($sElement = "") Local $isFoc = _FFCmd("FFau3.isfocused(" & $sElement & ")") Return $isFoc EndFunc ;==>_FFIsFocused Now, the javascript part is tested and it does return successfully.
      After a lot of try/fails I inserted an alert box in order to display the object being compared.
      Here is what I got
       
      The focused object is: [object XULElement]
      The object that I send for comparing is [object HTMLInputElement]
      Why is that?