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

    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
      Brian
    • BlazerV60
      By BlazerV60
      Hello all,
      I've been trying to figure out how to launch Google Chrome in the background (hidden) but it doesn't seem possible. I've tried the following methods:
      ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", "", "", @SW_HIDE) Also I've tried:
      ShellExecute(@ComSpec, "/c start chrome.exe","","",@SW_HIDE) Lastly I tried:
      RunWait('"'&@ProgramFilesDir&'\Google\Chrome\Application\chrome.exe" --silent-launch',@ScriptDir)  
      But all of them launch my chrome browser without hiding it. Does anyone know a workaround for this or if AutoIT just can't Chrome? 
      Bonus points if you know how to make it launch chrome hidden and make it go to https://www.autoitscript.com
       
      Thank you,
      Brian
    • 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
    • ur
      By ur
      We can select elements in IE using their IDs as below.
      Local $oDiv = _IEGetObjById($oIE, "x-auto-16-input") But to one button in the webpage, there is no ID to it.
      In selenium we have option to select this element using the CssSelector and clicked the button using below code in c# selenium.
      driver.FindElement(By.CssSelector("button.x-btn-text")).Click(); What is the alternative for this in AUtoIT?
    • Tippex
      By Tippex
      I'm having a problem with _IEBodyReadText() which is a function from the IE.au3 UDF include.
      My problem is that randomly it will crash my script with:
      Return SetError($_IESTATUS_Success, 0, $oObject.document.body.innerText) Return SetError($_IESTATUS_Success, 0, $oObject.document.body^ ERROR I don't know why the error isn't caught by __IEErrorHandlerRegister but looking at this function, I can see that there is a check done by IsObj($oObject) to ensure that the object "$oObject" exists but no check that it contains the property "innerText"
      ; #FUNCTION# ==================================================================================================================== ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IEBodyReadText(ByRef $oObject) If Not IsObj($oObject) Then __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidDataType") Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf If Not __IEIsObjType($oObject, "browserdom") Then __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidObjectType", "Expected document element") Return SetError($_IESTATUS_InvalidObjectType, 1, 0) EndIf ; Return SetError($_IESTATUS_Success, 0, $oObject.document.body.innerText) EndFunc ;==>_IEBodyReadText I'm struggling to find out how to test if "$oObject.document.body.innerText" exists before allowing the following Return statement to reference it with the assumption that it does exist (crashing my script when it doesn't).
      Any ideas please?