Jump to content

Converting _IETableWriteToArray to _FFTableWriteToArray


Jfish
 Share

Go to solution Solved by Danp2,

Recommended Posts

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

Link to comment
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

Link to comment
Share on other sites

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

Link to comment
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

Link to comment
Share on other sites

  • Solution

#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]
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...