Jump to content
Sign in to follow this  
Jfish

Converting _IETableWriteToArray to _FFTableWriteToArray

Recommended Posts

Jfish

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
Danp2

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
Jfish

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
Jfish

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
Danp2

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
Jfish

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
Jfish

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
Danp2

#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]
  • Like 1

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

    • careca
      By careca
      Hi, i feel im close to getting it to work, but there must be something im missing that's probably easy for you experts.
      #include <IE.au3> #include <File.au3> #include <MsgBoxConstants.au3> $Visible = 1 Local $oIE $oIE = _IECreate("https://beemp3s.net/mp3-download.html", 0, $Visible, 1, 1) _IELoadWait($oIE) If $oIE <> @error Then ;_ArrayText() _QuerySite('Finding Hope - Without You') ;_IEQuit($oIE) ;Exit Else MsgBox(64 + 262144, 'Fail', 'Could not create a new window') EndIf ;============================================================================= Func _QuerySite($Name) Local $oIE_ObjectToSearch = _IEGetObjById($oIE, 'query') _IEDocInsertText($oIE_ObjectToSearch, $Name) Local $oIE_ObjectToClick = _IEGetObjById($oIE, "search-action") _IEAction($oIE_ObjectToClick, 'click') _IELoadWait($oIE, 2000) ;============================================================================= Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12") _IEAction($oSubmitClick, "click") _IELoadWait($oIE, 2000) ;============================================================================= Local $oBtns = _IETagNameGetCollection($oIE, "div") For $oBtn In $oBtns If String($oBtn.classname) = "col-md-12" Then If String($oBtn.innertext) = "Download / Play" Then ConsoleWrite($oBtn.innertext & @CRLF) _IEAction($oBtn, 'click') EndIf EndIf Next ;============================================================================= ;Local $oElements = _IETagNameAllGetCollection($oIE) ;For $oElement In $oElements ; If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText) ;Next ;============================================================================= ;_IEQuit($oIE) ;Exit ;============================================================================= EndFunc ;==>_QuerySite ;============================================================================= Func _ArrayText() If FileExists('Titles.txt') Then Local $FO = FileOpen('Titles.txt') Local $R2A = FileReadToArray($FO) Local $iLineCount = @extended FileClose($FO) For $f = 0 To $iLineCount - 1 ConsoleWrite($f & ' - ' & $R2A[$f] & @CRLF) _QuerySite($R2A[$f]) Next Else MsgBox(64 + 262144, 'Fail', 'Could not find the file Titles.txt') EndIf EndFunc ;==>_ArrayText ;============================================================================= The idea is to get into this site, write into the search and click, which i did, but now the problem is clicking in any of the buttons in the results page, im looking for a way to click the first one, it always matches to what i want, so no need to fiddle around.
      Site
      Thanks for help in advance.

    • yoschga
      By yoschga
      is there a possibility to let ie.au3 click into a form? i use on a project where i need to click into a form where items are loaded just writing it in or fill the form is no option
       

    • tommytx
      By tommytx
      ConsoleWrite("Hello Dolly on Line 1" & @CRLF) #include <IE.au3> ConsoleWrite("Hello Dolly on Line 5" & @CRLF) Local $oIE = _IECreate("www.autoitscript.com") ConsoleWrite("Hello Dolly on Line 10" & @CRLF) Can anyone put me on the right track to troubleshoot this one.. the IE browser is not opening.. it is not my primary browser since FF is but that has not been a problem in the past.. it all seems to work including compile but the generation of the IE browser.. Never had any problem before.. below is the results of the run.. any ideas on where I might look.. that is the only error i get and its only after a 30 second delay.. I suppose a time out..
       
      ; >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "G:\show_pos.au3\test.au3"
      ; Hello Dolly on Line 1
      ; Hello Dolly on Line 5
      ; --> IE.au3 T3.0-2 Error from function _IECreate,  (Browser Object Creation Failed)
      ; Hello Dolly on Line 10
      ; >Exit code: 0    Time: 30.46
       
    • ohaya
      By ohaya
      Hi,
      I am still really new with AutoIT.  We are using it to automate logging into web sites and I have encountered problems with focus.  The target web page is configured to put the cursor into the first text field (username) when the page is loaded, and when I run the AutoIT script, which does the log in seems like it is just not starting where I expect it to be.  
      I have been kind of using ToolTip() to kind of help with debugging, but now I am wondering if the calls to ToolTip() are causing the focus to be messed up.  
      For example, at least visually, when the ToolTip() is called, I can see the cursor disappear from the web page text field and they when I do anything that is supposed to send keystrokes, they are going off somwhere else ("never-neverland").
      But when I remove some of the ToolTip() calls, it works correctly.
      So the questions I have are:
      1) Do the ToolTip() calls interfere with/change where the focus on the target page are?
      2) In general, what are the "rules" for where ToolTip can be used "safely" (== doesn't interfere with focus)?
      Thanks,
      Jim
       
    • RamaKrishna9
      By RamaKrishna9
      What are the minimum system requirements(like Windows OS version, IE browser version, etc,.) for IE.au3(3.3.14.2) to work properly?
×