Jump to content

Automate firefox


Bert
 Share

Recommended Posts

Great library Stilgar - thankyou!

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

  • Replies 251
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Sorry! How can i read or get URL from address bar?

Thanks in advance!

#include <FF.au3>

$Socket = _FFConnect() ; connecting to FF / MozRepl
$sHREF = _FFSetGet($Socket,".location.href") ; the current URL
MsgBox(64,"",$sHREF)oÝ÷ Úߢ»ayÚºg§¶åÉ«­¢+ØÀÌØíÍ!Iô}MÑÐ ÀÌØíM½­Ð°ÅÕ½Ðì¹UI0ÅÕ½Ðì
Edited by Stilgar
Link to comment
Share on other sites

#region #CURRENT# ==============================================================
;_FFAction
;_FFClick
;_FFClickImage
;_FFClickImageBySize
;_FFClickLink
;_FFConnect
;_FFDisConnect
;_FFDisPatchKeyEvent
;_FFFormCheckBox
;_FFFormGetLength
;_FFFormOptionselect
;_FFFormRadioButton
;_FFFormReset
;_FFFormSubmit
;_FFFrameEnter
;_FFFrameGetSelected
;_FFFrameLeave
;_FFGetLength
;_FFGetObject
;_FFGetValueById
;_FFGetValueByName
;[b]_FFGetValueByXPath[/b]; now is _FFXpath
;_FFLinksGetAll
;_FFLoadWait
;_FFOpenURL
;_FFQuit
;_FFReadHTML
;_FFReadText
;_FFSearch
;_FFSetGet
;_FFSetValueById
;_FFSetValueByName
;_FFStart
;_FFTabAdd
;_FFTabClose
;_FFTabCloseAll
;_FFTabDuplicate
;_FFTabExists
;_FFTabGetLength
;_FFTabGetSelected
;_FFTabSetSelected
;_FFTableGetCell
;_FFTableWriteToArray
#endregion #CURRENT#;===========================================================

Seem _FFXpath somtimes returns "" when fail not always 0

Link to comment
Share on other sites

What did you mean with "wrong query"? A query that found nothing or a query with a wrong expression?

If you try this:

_FFXPath($Socket,"qwert")

there's nothing wrong, but the expression can't find anything.

If you try this:

_FFXPath($Socket,"////")

then you run into an error, because that's an illegal expression.

If've tried many many things with it and I never have a problem with it, IF you use the right return types and XPath queries.

You can look for examples there:

Evaluate examples with greasemonkey

Edited by Stilgar
Link to comment
Share on other sites

How would or could you intercept a http request before the page finishes loading?

Example. A user types or click a url. Then firefox starts to transfer the page. I would like to get the url before the page is loaded. I know I can use "$sHREF = _FFSetGet($Socket,".location.href")", but I am not sure at what point the location changes. The page status changes immediately in the statusbar, but I do not know how to access it with firefox 3. I have tried window.content.status , but it is not working. Any help would be appreciated.

BTW.

:P Thank you Stilgar for FF.au3. You are awesome.

Link to comment
Share on other sites

What did you mean with "wrong query"? A query that found nothing or a query with a wrong expression?

If you try this:

_FFXPath($Socket,"qwert")

there's nothing wrong, but the expression can't find anything.

If you try this:

_FFXPath($Socket,"////")

then you run into an error, because that's an illegal expression.

If've tried many many things with it and I never have a problem with it, IF you use the right return types and XPath queries.

You can look for examples there:

Evaluate examples with greasemonkey

I see, It works fine now :P

When I test with multiple profiles, above 20 profiles at the sametime, there's some issues with _FFXpath and _FFSearch. _FFXpath hang on and _FFSearch couldn't find a string. They don't happen often so I haven't recorded them yet, When they happend again I will log them.

Good work ! :unsure:

Link to comment
Share on other sites

@drdave:

Thank you!

You can try it instead of the status text with the nsIWebProgress interface of FireFox, e.g. with the commands:

_FFSetGet($Socket,"window.getBrowser().webProgress.busyFlags")

_FFSetGet($Socket,"window.getBrowser().webProgress.isLoadingDocument")

@trinitrotoluen:

How did you use _FFXpath if it "hangs"?

Have you tried to change the $iDelay parameter (the last one) for _FFSearch ?

Link to comment
Share on other sites

@drdave:

Thank you!

You can try it instead of the status text with the nsIWebProgress interface of FireFox, e.g. with the commands:

_FFSetGet($Socket,"window.getBrowser().webProgress.busyFlags")

_FFSetGet($Socket,"window.getBrowser().webProgress.isLoadingDocument")

@trinitrotoluen:

How did you use _FFXpath if it "hangs"?

Have you tried to change the $iDelay parameter (the last one) for _FFSearch ?

Thanks Stilgar. I am able to get access to the loading page in 0.3 seconds using nsIWebProgress. Appreciated.

Link to comment
Share on other sites

@trinitrotoluen:

Can you show me an example what do you tried to do?

Have you looked at the examples in the docu?:

#Include <Array.au3>
#Include <FF.au3>

$Socket = _FFConnect()

If $Socket > -1 Then
    _FFTabAdd($Socket, "http://ff-au3-example.thorsten-willert.de/")

    MsgBox(64, "Number of password fields:", _FFXPath($Socket, "//input[@type='password']", "", 1))

    MsgBox(64, "Fieldset-Legend:", _FFXPath($Socket, "//form[@id='Programmiersprache']/fieldset/legend"))

    MsgBox(64, "Text from 0ption 5:", _FFXPath($Socket, "//option[5]"))

    $vTmp = "Method: " & _FFXPath($Socket, "//form[2]/@method") & @crlf
    $vTmp &= "Action: " & _FFXPath($Socket, "//form[2]/@action")
    MsgBox(64, "Form 2", $vTmp)

    $aArray = _FFXPath($Socket,"//option","value",7)
    _ArrayDisplay($aArray)

EndIf

I see the documentation for this interface is not really good.

With:

_FFSetGet($Socket,"window.getBrowser().webProgress.isLoadingDocument")

can you check if a document is loading.

With:

_FFSetGet($Socket,"window.getBrowser().webProgress.busyFlags")

can you check the current loading state. busyFlags are:

BUSY_FLAGS_NONE = 0

BUSY_FLAGS_BUSY = 1

BUSY_FLAGS_BEFORE_PAGE_LOAD = 2

BUSY_FLAGS_PAGE_LOADING = 4

Edited by Stilgar
Link to comment
Share on other sites

Thank Stilgar for the ex of nsIWebProgress :P

Can you show me an example what do you tried to do?

for ex : I have the string : "Number of password fields", I wanna get the Xpath query for this string.

Of course I can do it with Xpather, but I wanna ask if there's a way to do with coding.

Link to comment
Share on other sites

Ok you have the string "Number of password fields" what you wanna do then with xpath?

Xpath is usefull if you know e.g. the id of an div and you would get the text of it:

<div id='id2'>text</div>

=>

$sDivText = _FFXpath($Socket,"//div[@id='id2']")

or you can set an value:

_FFXPath($Socket,"//textarea[@name='sonderangaben']","value='Number of password fields'",5)

...

Edited by Stilgar
Link to comment
Share on other sites

Hi Stilgar, thank you very much for this wonderful automation library. I've read your example to write inner HTML directly to the body. Can you give an example of how to write scratch HTML and thus release previous content of a page using FF.au3? I mean

[html][...][/...][/html]
etc..

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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