Sign in to follow this  
Followers 0
Jfish

Converting _IETableWriteToArray to _FFTableWriteToArray

13 posts in this topic

I am embarrassed to ask this but it is not obvious to me after searching around the forum :> .  I am trying to convert a working IE script to read shipping information from a table in our shopping cart solution to FF. 

This is the working IE version:

Local $oTable = _IETableGetCollection($oIE,20)
Local $3dcartShipToTable = _IETableWriteToArray($oTable)

I grabbed the ff.au3 UDF and found the thread to replace the "/" in the code.  I can start it up etc.  Then I found the thread to grab the MozRepl plugin (which I did).  However, this code:

_ffStart("http://pacebands.3dcartstores.com/admin")
MsgBox("","","hold the phone")
$ffarray=_FFTableWriteToArray(11)
_ArrayDisplay($ffarray)

Results in this error:

__FFStartProcess: ""C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -new-window "http://pacebands.3dcartstores.com/admin"  "-repl 4242 "
_FFConnect: OS: WIN_81 WIN32_NT 9600 
_FFConnect: AutoIt: 3.3.12.0
_FFConnect: FF.au3: 0.6.0.1b-10
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect ==> Timeout: TCPConnect Error: 10061
_FFConnect ==> General Error: Timeout: Can not connect to FireFox/MozRepl on: 127.0.0.1:4242
__FFSend ==> Socket Error
_FFCmd ==> Error return value
_FFTableWriteToArray ==> Invalid value: (INT) $vTable: 11

I am sure this is simple and I am doing something wrong but I am getting a bit lost in all the ff.au3 threads.  Can anyone set me straight?


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites



Make sure that you have MozRepl started (look under Tools > MozRepl menu). You should make sure that "Activate on startup" is selected so that you don't run into this issue every time.

Share this post


Link to post
Share on other sites

Thanks @Danp2 - I found tools with "ALT + T" and did that.  That error is now resolved.  Now I am just trying to find that particular table.  I will play with it a bit more and report back...


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Okay, another dumb question  ...

I can't get the table function to work.  I looked in the UDF and here is what I came up with:

; this works
Local $oTable = _IETableGetCollection($oIE,20)
Local $3dcartShipToTable = _IETableWriteToArray($oTable)
; is the syntax in ff for the above this? b/c it does not work
$ffarray=_FFTableWriteToArray(19)

Do I need to get the table object first and pass that?  The UDF suggests that the first parameter can be the index value if $sMode is defaulted to index (at least that is how I read it).  It also looks like you don't need to "attach" to the instance of FF like you do in IE.  If that is not the case, please let me know.  Here is the error I get:

__FFSend ==> Socket Error
_FFCmd ==> Error return value
_FFTableWriteToArray ==> Invalid value: (INT) $vTable: 20

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

It's telling you that it doesn't detect that many tables on the current page. The UDF needs to know which tab you intend to interact with, so you will need to establish that first (see _FFWindowSelect and _FFTabSetSelected) and then call _FFTableWriteToArray.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks for hanging in there with me on this one - I think the FF UDF has a learning curve (or it could just be me).  Either way, I have another question ...

If the tab I am interested in is the only open tab I should be able to do this, correct?:

_FFWindowSelect()
_FFTabSetSelected()
$ffarray=_FFTableWriteToArray(20)
_ArrayDisplay($ffarray)

***EDIT*** I added

_FFConnect()

It now finds the pages etc.  However, it can't seem to find the table still ...

_FFConnect: OS: WIN_81 WIN32_NT 9600 
_FFConnect: AutoIt: 3.3.12.0
_FFConnect: FF.au3: 0.6.0.1b-10
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     632
_FFConnect: Browser:    Mozilla/5.0 (Windows NT 6.3; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0
__FFSendJavaScripts: Sending functions to FireFox .......... done
__FFSend: try{repl.enter(Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser"))}catch(e){'_FFCmd_Err';};
__FFRecv: [object ChromeWindow] - {0: {...}, 1: {...}, 2: {...}, 3: {...}, 4: {...}, 5: {...}, 6: {...}, ...}
__FFSend: try{FFau3.tmp=document.title;document.title='FFAU31143185670'}catch(e){'_FFCmd_Err';};
__FFRecv: FFAU31143185670
__FFSend: try{document.title=FFau3.tmp}catch(e){'_FFCmd_Err';};
__FFRecv: 3DCart v6.4.1 Store Manager - Mozilla Firefox
_FFWindowGetHandle: 0x0052103A
__FFSend: try{gBrowser.tabContainer.selectedIndex = 0}catch(e){'_FFCmd_Err';};
__FFRecv: 0
__FFSend: FFau3.WCD=window.content.top.document;
__FFRecv: [object XrayWrapper [object HTMLDocument]] - {location: {...}, home: {...}, stats: {...}, crm: {...}, search1: {...}, view-store: {...}, email: {...}, ...}
[object XrayWrapper [object HTMLDocument]] - {location: {...}, home: {...}, stats: {...}, crm: {...}, search1: {...}, view-store: {...}, email: {...}, ...}
_FFTableWriteToArray ==> General Error: //table[20] not found.
Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Does the site use frames? If so, take a look at the online help entry for _FFFrameEnter.

Share this post


Link to post
Share on other sites

Okay, I have more info.  First, I was able to get some arrays back for tables.  However, not the one I want.  I also noticed that the index does not seem to follow the same rules as IE so my assumption I could use  the same table number seems wrong.  That said, this is the exact table I am after:

<table width="100%" cellpadding="2" cellspacing="0" border="0" style="padding-top:4px;padding-bottom:4px;" class="tablenooutline" id="Table13">
            <tr>
              <td class="searchheader">Name:</td>
              <td>Doe, Jane</td>
            </tr>
            <tr>
              <td class="searchheader">Company:</td>
              <td></td>
            </tr>
            <tr>
              <td class="searchheader" valign="top">Address:</td>
              <td>555 Main Street<!--START: shipAddress2--><br>
                APYT #1<!--END: shipAddress2--> 
                <br>
                Boston, MA, 02110, US </td>
            </tr>
            <tr>
              <td class="searchheader">Phone:</td>
              <td>6175551212</td>
            </tr>
            <!--START: addressType--><!--END: addressType-->
            <tr>
              <td class="searchheader">Method:</td>
              <td > Free Shipping 
                <!--START: editShippingMethod--><!--END: editShippingMethod--></td>
            </tr>
          </table>

The code I tried to use to get at it was:

_FFConnect()
_FFWindowSelect()
_FFTabSetSelected()
$ffarray=_FFTableWriteToArray("Table13","id")
_ArrayDisplay($ffarray)

I get this error when searching on that table:

_FFTableWriteToArray ==> General Error: //table[@id='Table13'] not found.

I do not believe frames are in use.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Can you post a file containing the complete HTML page?

Share this post


Link to post
Share on other sites

#include <FF.au3>
#include <Array.au3>

Local $url = 'orderpage.html'

_FFConnect(Default, Default, 3000)

_FFWindowSelect($url, 'href', False)
_FFTabSetSelected($url, 'href')

$ffarray=_FFTableWriteToArray("Table13","id")
_ArrayDisplay($ffarray)

With the above code, the array would get created but it's contents were incorrect. I found what appears to be a bug in _FFTableWriteToArray. Find the following line in FF.au3:

$aTable[$j][$i] = $aRows[$i + 1]

and change it to:

$aTable[$j][$i] = $aRows[$j + 1]
1 person likes this

Share this post


Link to post
Share on other sites

You're welcome

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

    • tarretarretarre
      By tarretarretarre
      AutoIt-SocketIo
      Yep yep, this is pretty much an attempt to port the existing project's concept https://socket.io/ to AutoIt's Codebase. So i will not go in to so much detail.
      This is how the communication is done http://i.imgur.com/0mMfsBD.png Each client is isolated to the server http://i.imgur.com/rVO2LFb.png Features
      Easy API VarType Translation (Example: If the server sends an int, the client will receive an int and vice versa) Fully featured examples Data encryption (Using Autoit's UDF Crypt.au3) Limitations / Drawbacks
      Every Broadcast/Emit is limited to a maximum of 16 parameters Every Callback Function has to have the same number of parameters as the Broadcasted/Emited event It is not possible to Broadcast/Emit objects Only 1D-arrays are allowed to be Broadcasted/Emitted (2D arrays will probably never be supported) Changelog
      Version 1.4.0 (This update DOES NOT break scripts)
      Added a new server method: _Io_getSockets which will return an array of all sockets. See more in the doc Added a banning-system, see more at: _Io_getBanlist, _Io_Ban, _Io_Sanction, _Io_IsBanned Added a new default event for clients banned. See more at default events Added two new client and server methods _Io_setEventPreScript And _Io_setEventPostScript. The intent for these is to not DRY when doing debug \ tasks that requires to be ran before or after events. Added a new client and server method _Io_ClearEvents. Added a third optional parameter to _Io_On called $socket, you may only pass the socket returned from _Io_Listen or _Io_Connect. The intent for this change is to allow for server + client in the same envoirment. Added a second parameter to _Io_Loop called $WhoAmI which should used with the new enums $_IO_SERVER and $_IO_CLIENT. The intent for this change is to allow for server + client in the same envoirment. Added a new client method _Io_TransferSocket. Added a new server method _Io_getActiveSocketCount. Optimations, avoiding Redims and unnecessary nested arrays as good as possible etc. Version 1.3.0 (This update DOES NOT break scripts)
      Got rid of unnecessary Redims with sockets and subscriptions in the main loop (This increased write performence greatly) Changed $iMaxDeadSocketsBeforeTidy from 100 to 1000 Changed _Io_setRecvPackageSize($nPackageSize = 2048) to _Io_setRecvPackageSize($nPackageSize = 4096) because 2017. Added Tests for both subscriptions and the automatic TidyUp Added a new server method: _Io_getMaxConnections Added a new server method: _Io_getMaxDeadSocketsCount Added a fifth parameter to the _Io_Listen method called $iMaxConnections which defaults to 100000. If the iMaxConnection + 1 user connects, they will be instantly disconnected. Added a parameter to _Io_Disconnect called $socket which defaults to null. If the iMaxConnections + 1 client connects, they will be instantly disconnected. Version 1.2.0 (This update DOES NOT break scripts)
      Added an option to set the packet-size of TCP-transports, see _Io_setRecvPackageSize Got rid of unnecessary StringLen's in _Io_loop Changed __Io_TidyUp to _Io_TidyUp and added it to the public Api reference list. Changed $iMaxDeadSocketsBeforeTidy default value from 1000 to 100 and added an option to disable it, read more at _Io_Listen Changed $bAutoReconnect from False to True. Fixed gitignore epicZ fail Improvemend Documentation Version 1.1.0 (This update DOES NOT break scripts)
      Fixed bug when Emitting / Broadcasting without any parameters causing a $fCallback crash Optimized Package-handling once again. Added 1D-Array support (Endless nestning). Added Subscriptions (See _Io_Subscribe _Io_Unsubscribe and _Io_BroadcastToRoom). Added new example for subscriptions (Be sure to use different room names when joining with clients) Added Unit testing (See Tests\Runner.au3 and Tests\Tests.au3, to run tests you need a udf found here: https://github.com/tarreislam/Autoit-Unit-Tester) Version 1.0.0
      (This update DOES NOT break scripts) Added data encryption (Using Autoit's UDF Crypt.au3) See more at _Io_EnableEncryption Added new method _Io_Disconnect which can be used with both servers and clients Improved package-handling to increase performance Increased the limit of Broadcasted/Emit parameters from 10 to 16 Api methods
      Server methods
      _Io_Listen($iPort, $iAddress = @IPAddress1, $iMaxPendingConnections = Default, $iMaxDeadSocketsBeforeTidy = 1000, $iMaxConnections = 100000) _Io_Subscribe(ByRef $socket, $sRoomName) _Io_Unsubscribe(ByRef $socket, $sRoomName = null) _Io_Broadcast(ByRef $socket, $sEventName, $p1, $p2, ...$p16)  
      _Io_BroadcastToAll(ByRef $socket, $sEventName, $p1, $p2, ...$p16) _Io_BroadcastToRoom(ByRef $socket, $sDesiredRoomName, $sEventName, $p1, $p2, ...$p16) _Io_socketGetProperty(ByRef $socket, $sProp = Default) _Io_getSockets($bForceUpdate = False, $socket = $__g_io_mySocket, $whoAmI = $__g_io_whoami) _Io_getDeadSocketCount() _Io_getSocketsCount() _Io_getActiveSocketCount() _Io_getMaxConnections() _Io_getMaxDeadSocketsCount() _Io_getBanlist($iEntry = Default) _Io_Ban($socketOrIp, $nTime = 3600, $sReason = "Banned", $sIssuedBy = "system") _Io_Sanction($socketOrIp) _Io_IsBanned($socketOrIp) _Io_TidyUp() Client methods
      _Io_Connect($iAddress, $iPort, $bAutoReconnect = True) _Io_Reconnect(ByRef $socket) Server and Client methods
      _Io_setEventPreScript($fCallback) _Io_setEventPostScript($fCallback) _Io_getVer() _Io_On(Const $sEventName, Const $fCallback, $socket = $__g_io_mySocket) _Io_Emit(ByRef $socket, $sEventName, $p1, $p2, ...$p16) _Io_Loop(ByRef $socket, $whoAmI = $__g_io_whoami) _Io_LoopFacade() _Io_EnableEncryption($sFileOrKey, $CryptAlgId = $CALG_AES_256) _Io_Disconnect($socket = null) _Io_setRecvPackageSize($nPackageSize = 4096) _Io_ClearEvents() _Io_TransferSocket(ByRef $from, ByRef $to) Default events
      Server events
      connection Client events
      banned Server and Client events
      disconnect View source on github
       
      Autoit-Socket-IO-1.0.0.zip (OLD!)
      Autoit-Socket-IO-1.1.0.zip (OLD)
      Autoit-Socket-IO-1.3.0.zip (OLD)
      Autoit-Socket-IO-1.4.0.zip (NEWEST 2017-08-11)
    • timmalos
      By timmalos
      Hello all.
      In case this is interesting few of you, I share my AMCP 2.1 protocol UDF in AutoIT. This protocol is used by CasparCG server, which is a Windows and Linux software used to play out professional graphics, audio and video to multiple outputs as a layerbased real-time compositor. It has been in 24/7 broadcast production since 2006. It's free and opensource.
      The UDF I share allows communication between an AutoIt based client and the CasparCG, based on following documentation : http://casparcg.com/wiki/CasparCG_2.1_AMCP_Protocol
      If you want more details on CasparCG :  official WebSite or have a look to this video
      I'm currently building a full Client based on AutoIt, with many features like drag-and-drop layers, but sadly I can't share it right now, might come later. Don't hesitate to ask questions if you have any or need a basic example.
      The only requirement for this UDF is the other Event-driven TCP UDF by Kip
       
       

      AMCP_shared.au3
      TCP.au3
    • 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?