Jump to content

FF.au3 (V0.6.0.1b-10)


Stilgar
 Share

Recommended Posts

Hi, I can't do with this :

<input type="file" size="35" name="upfile"/>

Right, because _FFObj is searching the attribute "value", so it fails at this code.

But you can do this

_FFXpath("//input[@type='file' and @name='upfile']","",9)
_FFObj("xpath.value='c:\\text.txt'")

or this:

_FFXpath("//input[@type='file' and @name='upfile']","value='c:\\text.txt'",9)
Link to comment
Share on other sites

Here is a new question (maybe a dumb one, but...)

How can we call a javascript function, defined in the current HTML page?

I thought it should be as simple as

_FFCmd("test()")

if the function in the page is defined as

<script type="text/javascript">
    function test(){
        alert("SIMPLE TEST");
    }
</script>

But I can't figure how to make this work. Always getting a "__FFRecv: _FFCmd_Err" error message in the console

Can anybody help please?

Link to comment
Share on other sites

Here is a new question (maybe a dumb one, but...)

How can we call a javascript function, defined in the current HTML page?

I thought it should be as simple as

_FFCmd("test()")

if the function in the page is defined as

<script type="text/javascript">
    function test(){
        alert("SIMPLE TEST");
    }
</script>

But I can't figure how to make this work. Always getting a "__FFRecv: _FFCmd_Err" error message in the console

Can anybody help please?

If you only send "test()" then the function is searched in the window-context.

This one works:

_FFCmd("content.wrappedJSObject.test()")

look also there:

https://developer.mozilla.org/en/wrappedJSObject

Link to comment
Share on other sites

I've been using IE.au3 for a while and am now trying to learn how to do all of the same things I need to do with FF.au3. I'm having some trouble figuring out how to retrieve some element properties like innerHtml, because the returned value appears to be the empty string no matter what I try. The code segment I'm currently running is this:

Local $splashDiv = _FFObjGet("isc-login-swoosh", "class")
MsgBox(0, "", _FFCmd(".getElementsByClassName('isc-login-swoosh')[0].innerHtml"))
Local $array = _FF_ElementGetPosition("getElementsByClassName('isc-login-swoosh')[0]")
If (@Error == 0) Then MsgBox(0, "", $array[0] & ", " & $array[1])

Running from SciTE, this is the output I get to the console:

__FFSend: try{window.content.frames["top"].document.getElementsByClassName('isc-login-swoosh')[0]?1:0;}catch(e){'_FFCmd_Err';};
__FFRecv: 1
__FFSend: try{window.content.wrappedJSObject.frames["top"].document.getElementsByClassName('isc-login-swoosh')[0].innerHtml}catch(e){'_FFCmd_Err';};
__FFRecv: 
__FFSend: try{repl.inspect(FFau3.findPos)}catch(e){'_FFCmd_Err';};
__FFRecv: <undefined> is empty
__FFSend: try{FFau3.findPos=function findPos(obj){var curleft=curtop=0;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}while(obj=obj.offsetParent);return curleft+' '+curtop;}}}catch(e){'_FFCmd_Err';};
__FFRecv: function() {…}
__FFSend: try{FFau3.findPos(content.document.getElementsByClassName('isc-login-swoosh')[0])}catch(e){'_FFCmd_Err';};
__FFRecv: 490 256

So I can confirm that the element exists and I can get its position using the _FF_ElementGetPosition() function. Using Firebug, I've also checked that the innerHtml property should not be empty, and I have code using IE.au3 that returns the innerHtml property as expected. What gives? What am I doing wrong?

Link to comment
Share on other sites

If you only send "test()" then the function is searched in the window-context.

This one works:

_FFCmd("content.wrappedJSObject.test()")

look also there:

https://developer.mozilla.org/en/wrappedJSObject

Thank you, this syntax is working.

So the question was not so dumb I thought, since I never heard of that (requires knowing on Mozilla internals, which may not be common knowledge for those just willing to use the FF package)

Link to comment
Share on other sites

@Rishodi:

All attributes and methodes from DOM/Javascript are casesensitiv.

I think you want the value from "innerHTML" and not from "innerHtml".

https://developer.mozilla.org/en/DOM/element.innerHTML

You can see there:

__FFSend: try{window.content.frames["top"].document.getElementsByClassName('isc-login-swoosh')[0]?1:0;}catch(e){'_FFCmd_Err';};
__FFRecv: 1

that the element is found, but there's no attribute "innerHtml"

You can write this a bit simpler if you using Xpath instead of objects:

$sInnerHTML = _FFXpath("//*[@class='isc-login-swoosh']","innerHTML",9) ; gets the innerHTML from the first element with the class 'isc-login-swoosh'

[EDIT]

@GerardJ:

Yes, but normaly you don't have to know the internals, or are the normal functions in the FF.au3 not enough?

Edited by Stilgar
Link to comment
Share on other sites

@GerardJ:

Yes, but normaly you don't have to know the internals, or are the normal functions in the FF.au3 not enough?

You are probably right, I had to activate this javascript function because the onchange event on the form select I was testing is not yet managed by FF.au3.

But I'm sure we could find some cases where it could be useful, anyway, to activate a javascript function defined inside a page we are managing with FF.au3, so it might be worth adding such an example inside the _FFCmd documentation.

Link to comment
Share on other sites

@Rishodi:

All attributes and methodes from DOM/Javascript are casesensitiv.

I think you want the value from "innerHTML" and not from "innerHtml".

https://developer.mozilla.org/en/DOM/element.innerHTML

Ah-ha! I had become so accustomed to automating IE within AutoIt that I became indifferent to the case sensitivity of the DOM. That was indeed my problem. D'oh! As for XPath, I was just introduced to it, so I appreciate the example. Thanks for your help!
Link to comment
Share on other sites

How can I use FF.au3 to clear Firefix History/cookies etc?

; Cookies
_FFCmd("Components.classes['@mozilla.org/cookiemanager;1'].getService(Components.interfaces.nsICookieManager).removeAll();")

; History
_FFCmd("Components.classes['@mozilla.org/browser/nav-history-service;1'].getService(Components.interfaces.nsIBrowserHistory).removeAllPages();")

; Cache
_FFCmd("Ci=Components.interfaces;Components.classes['@mozilla.org/network/cache-service;1'].getService(Ci.nsICacheService).evictEntries(Ci.nsICache.STORE_ANYWHERE);")

Look also at:

https://developer.mozilla.org/en/nsICookieManager

https://developer.mozilla.org/en/nsIBrowserHistory

https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsICacheService

Edited by Stilgar
Link to comment
Share on other sites

I haven't been able to find useful information on this anywhere, so I wonder if anyone here could help me. I'm trying to use the DOM to find the relative position of a window object to the screen, or to the Firefox browser window. It's simple enough to find the size of the browser window (window.outerWidth/outerHeight) and its position relative to the screen (window.screenX/screenY), as well as the size of any window object (window.innerWidth/innerHeight) and the size of the screen (window.screen.width/height). However, I can't figure out how to find the position of a window object relative to the screen, or relative to the browser window. I'm sure everyone can see how useful this would be for an AutoIt script.

IE makes this easy with the non-standard window object properties screenLeft and screenTop, for which I have found no similar properties in Firefox. Is there any other way I could use to find the relative position of a window object in Firefox, or to find the size of all the browser toolbars, since that's basically what my request amounts to? If not, I may have to resort to a nasty workaround.

Link to comment
Share on other sites

I haven't been able to find useful information on this anywhere, so I wonder if anyone here could help me. I'm trying to use the DOM to find the relative position of a window object to the screen, or to the Firefox browser window. It's simple enough to find the size of the browser window (window.outerWidth/outerHeight) and its position relative to the screen (window.screenX/screenY), as well as the size of any window object (window.innerWidth/innerHeight) and the size of the screen (window.screen.width/height). However, I can't figure out how to find the position of a window object relative to the screen, or relative to the browser window. I'm sure everyone can see how useful this would be for an AutoIt script.

IE makes this easy with the non-standard window object properties screenLeft and screenTop, for which I have found no similar properties in Firefox. Is there any other way I could use to find the relative position of a window object in Firefox, or to find the size of all the browser toolbars, since that's basically what my request amounts to? If not, I may have to resort to a nasty workaround.

I'm not sure what you searching for. What you wanna do with this positions?

Or is there anything you looking for:

https://developer.mozilla.org/en/DOM/window

Aren't window.screenX/Y and window.screenLeft/Right the same?

http://www.javascriptkit.com/domref/windowproperties.shtml

Link to comment
Share on other sites

Posted Image Hi all,

Here is an helpFile FF3.chm for Firefox automation which is an adaptation of Stilgar's helpfile on his web

For safety reason you have to rename FF3.txt to FF3.chm

The forum doesn't allow transmitting a CHM File

Best Regards

Complementary information :

1 - To download this attachments you have to click on right button of your mouse and choosing "Saving target on"

Renaming FF3.txt in FF3.chm

2- When launching your chm files when the dialogbox appear unckeck "Always asking before opening file" and after click on OK , your chm file will be recognize like an help file by the system

Edited by LOULOU
Link to comment
Share on other sites

Posted Image Hi all,

Here is an helpFile FF3.chm for Firefox automation which is an adaptation of Stilgar's helpfile on his web

For safety reason you have to rename FF3.txt to FF3.chm

The forum doesn't allow transmitting a CHM File

Best Regards

Your attachment just opens up some garbage:

ITSF`ıé¢ý|ª{О É"æìý|ª{О É"æì`xT@Ì@þÌITSPT

ÿÿÿÿ j’].!Ðù É"æìTÿÿÿÿÿÿÿÿÿÿÿÿPMGL^ÿÿÿÿ//#IDXHDRÒÇ` /#ITBITS /#STRINGSÓ‡Z//#SYSTEMƒ~¡8/#TOPICSÒç`‰@/#URLSTRÒø0*/#URLTBLÒñ ‡ /#WINDOWSÒ°qL/$FIftiMain /$OBJINSTÒ²E•/$WWAssociativeLinks//$WWAssociativeLinks/PropertyÒ²A/$WWKeywordLinks//$WWKeywordLinks/PropertyÒ²=/_FFAction.htmî·/_FFAction.php_fichiers/#/_FFAction.php_fichiers/default.css‘ˆ!š//_FFAction.php_fichiers/injection_graph_func.js‘¢5ñ

Link to comment
Share on other sites

To download this attachments you have to click on right button of your mouse and choosing "Saving target on"

Renaming FF3.txt in FF3.chm and after all was good

did that and renamed. help file opens, but no content. see attachment.

Edited by dmob
Link to comment
Share on other sites

I'm not sure what you searching for. What you wanna do with this positions?

Or is there anything you looking for:

https://developer.mozilla.org/en/DOM/window

Aren't window.screenX/Y and window.screenLeft/Right the same?

http://www.javascriptkit.com/domref/windowproperties.shtml

I can't find what I'm looking for in the Gecko DOM Reference, so I wanted to check with someone more familiar before assuming it wasn't there. I'm using these coordinates to have AutoIt make a couple of clicks through a Java application in the browser.

screenX/Y and screenLeft/Top are unfortunately not the same. The former is for Gecko-based browsers and is the offset from the top left corner of the user's screen to the top left corner of the browser window. For example, if your browser is located at (40, 40) on the screen, then screenX/Y will give you (40, 40). The latter is IE-only and gives you the offset from the user's screen to a content window in the DOM. For example, if your browser is located at (40, 40) and you're trying to get the offset of the top-level window, screenLeft/Top will return something like (44, 190), which tells you that the left side of your browser skin is 4 pixels wide and your browser's titlebar and toolbars are 150 pixels high. As far as I can tell, Firefox will give you the size of the browser window as well as the size of any content window in the DOM, but there's no simple way to get the position of any content window relative to the browser window or to the screen.

Edited by Rishodi
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...