Sign in to follow this  
Followers 0
GMK

_FFCmd

2 posts in this topic

I'm trying to use _FFCmd to remove some child elements (and replace other child elements), but with no luck.

Simple example:

#include <FF.au3>
_FFStart("http://www.autoitscript.com/")
If Not _FFIsConnected() Then _FFConnect()
$eDoc = "window.content.top.document"
$eNLHSL1 = ".getElementsByClassName('NLHSL1')"
$iNLHSL1Length = _FFCmd($eNLHSL1 & ".length")
For $i = 0 To $iNLHSL1Length - 1
    $cmdNLHSL1 = _FFCmd(".documentElement.removeChild(" & $eDoc & $eNLHSL1 & "[" & $i & "]);")
Next
produces...
Running:(3.3.4.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\...\My Documents\Scripts\removechild.au3"    
__FFStartProcess: ""C:\Program Files\Mozilla Firefox\firefox.exe" -new-window "http://www.autoitscript.com/"  -repl 4242 
_FFConnect: OS: WIN_XP WIN32_NT 2600 Service Pack 3
_FFConnect: AutoIt: 3.3.4.0
_FFConnect: FF.au3: 0.6.0.1
_FFConnect: IP: 127.0.0.1
_FFConnect: Port:   4242
_FFConnect: Delay:  2ms
_FFConnect: Socket:     1672
_FFConnect: Browser:    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)
__FFSendJavascripts: Sending functions to FireFox .......... done
_FFLoadWait: . loaded in 15ms
__FFSend: try{FFau3 != null?1:0}catch(e){'_FFCmd_Err';};
__FFRecv: 1
__FFSend: try{window.content.top.document.getElementsByClassName('NLHSL1').length}catch(e){'_FFCmd_Err';};
__FFRecv: 5
__FFSend: try{window.content.top.document.documentElement.removeChild(window.content.top.document.getElementsByClassName('NLHSL1')[0]);}catch(e){'_FFCmd_Err';};
__FFRecv: _FFCmd_Err
__FFSend: try{window.content.top.document.documentElement.removeChild(window.content.top.document.getElementsByClassName('NLHSL1')[1]);}catch(e){'_FFCmd_Err';};
__FFRecv: _FFCmd_Err
__FFSend: try{window.content.top.document.documentElement.removeChild(window.content.top.document.getElementsByClassName('NLHSL1')[2]);}catch(e){'_FFCmd_Err';};
__FFRecv: _FFCmd_Err
__FFSend: try{window.content.top.document.documentElement.removeChild(window.content.top.document.getElementsByClassName('NLHSL1')[3]);}catch(e){'_FFCmd_Err';};
__FFRecv: _FFCmd_Err
__FFSend: try{window.content.top.document.documentElement.removeChild(window.content.top.document.getElementsByClassName('NLHSL1')[4]);}catch(e){'_FFCmd_Err';};
__FFRecv: _FFCmd_Err
+>11:34:41 AutoIT3.exe ended.rc:0
>Exit code: 0    Time: 6.099
I'm new to DOM programming, so any help would be appreciated. Thanks in advance!

Share this post


Link to post
Share on other sites



Well, I found something that works:

#include <FF.au3>
_FFStart("http://www.autoitscript.com/")
$eDoc = "window.content.top.document"
$eNLHSL1 = ".getElementsByClassName('NLHSL1')"
Do
    $cmdNLHSL1 = _FFCmd($eNLHSL1 & "[0].parentNode.removeChild(" & $eDoc & $eNLHSL1 & "[0]);")
Until $cmdNLHSL1 = "_FFCmd_Err"

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