Jump to content

Automate firefox


Bert
 Share

Recommended Posts

<input type="image" value="ok" border="0" name="s1" src="img/en/b/b1.gif" width="80" height="20" onmousedown="btm1('s1','','img/en/b/b2.gif',1)" onmouseover="btm1('s1','','img/en/b/b3.gif',1)" onmouseup="btm0()" onmouseout="btm0()"></input>

I'm having problem to click this image as this image doesn't return a link for me.

I can simulate the click with other images but not this.

Link to comment
Share on other sites

  • Replies 251
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi.

I'm new to FF.au3 and I'm discovering its possibilities.

It's seems to be a very fine piece of code, so I'm hoping I will be able to use it inside one of my projects at work.

I've been evaluating it all day (so in other words, this is my first day on using it) and i'm trying to interact with some HTML pages buit by an existing aplication.

One of pages is a list-box (a SELECT with options inside a form) so I used the _FFFormOptionselect() function. Its OK, I can select the value I want.

But the problem is that this select has an onchange event, and when using the _FFFormOptionselect() this event is not raised. SO the page does not work (and there is no submit buton, and the onchange is doing more than a simple submit so I cannot use a simple _FFSubmit call)

Is there a way to force this event using another function? or is this something missing in the _FFormOptionselect() function? (not a bug, but something not yet impemented..)

I did not check (yet) if the behaviour is the same for the other fonctions (checking a checkbox or a radio button having some onclick event or so) or if it is limited to the Optionselect

If someone could help me, please.

Link to comment
Share on other sites

@GerardJ:

Hi,

currently only the _FFClick* functions fires a click event, for the _FFForm* functions such things are not implemented yet.

@all:

Something to test in the new test-version V0.5.1.4:

FF.au3

Some "pseudo-object" functions:

- New: _FFObj: access to FireFox objects

- New: _FFObjDelete: deleting objects in the FFau3-object

- New: _FFObjGet: returns an "object" (string)

- New: _FFObjNew: creates a new object in the FFau3-object

example:

#include <FF.au3>

_FFConnect()
Do
    _FFTabAdd("http://ff-au3-example.thorsten-willert.de/")

    _FFXPath("//form[2]//input[position()=1]","",9) ; creates an internal object "xpath"
    MsgBox(64,"", _FFObj("xpath","type"))
    ; OR
    MsgBox(64,"", _FFObj("xpath.value"))
    _FFObj("xpath.checked=true")

    Sleep(5000)

    _FFOpenURL("google.com")

    If _FFObjNew("google", "window.content.document") Then
        MsgBox(64, "Cookie", _FFObj("google","cookie"))
        ; OR
        MsgBox(64, "Domain", _FFObj("google.domain"))
        _FFObjDelete("google") ; :D
    EndIf

    $sInput = _FFObjGet("q", "name") ; returns a string - not an  object!
    _FFObj($sInput, "value", "autoit")
    MsgBox(64, "Suche: ", _FFObj($sInput, "value"))

    _FFTabClose("Google", "label")

    _FFDisConnect()
Until Not _FFIsConnected()

Exit
Link to comment
Share on other sites

@GerardJ:

Hi,

currently only the _FFClick* functions fires a click event, for the _FFForm* functions such things are not implemented yet.

Thank you for your answer.

For the moment I will find a way to activate a copy on the javascript code defined in the onchange event handler so I'm not blocked, and later, when the events are implemented, I will just delete this temporary code.

===

By the way, it seems that the _FFFormSubmit() functions always returns an error if we try to submit with form name. The example code in your package is returning the error:

__FFSend: try{content.document.login.elements.length;}catch(e){"_FFFormSubmit_Error";};

__FFRecv: _FFFormSubmit_Error

_FFFormSubmit ==> No match: No Elements found in form: login

Same with your last version "0.5.1.4b-1" just retested.

Could you have a look, please?

Link to comment
Share on other sites

Thank you for your answer.

For the moment I will find a way to activate a copy on the javascript code defined in the onchange event handler so I'm not blocked, and later, when the events are implemented, I will just delete this temporary code.

===

By the way, it seems that the _FFFormSubmit() functions always returns an error if we try to submit with form name. The example code in your package is returning the error:

__FFSend: try{content.document.login.elements.length;}catch(e){"_FFFormSubmit_Error";};

__FFRecv: _FFFormSubmit_Error

_FFFormSubmit ==> No match: No Elements found in form: login

Same with your last version "0.5.1.4b-1" just retested.

Could you have a look, please?

This error is fixed now:

FF.au3

Link to comment
Share on other sites

Hello everybody,

sorry for my english, i am french...

Is that this udf can save the web page in local disk?

During the save of the page, I have messages of error which I shall like to avoid for my automatisaion.

These messages appear when an object of the page is not downloadable.

Thank you in advance for your answers. :D

Link to comment
Share on other sites

Is that this udf can save the web page in local disk?

During the save of the page, I have messages of error which I shall like to avoid for my automatisaion.

These messages appear when an object of the page is not downloadable.

How are you saving your page? what is the error you get? is it inside the Autoit console or on Windows?

A way to save pages is to first get the whole HTML from the current page using _FFReadHTML, and then use standard AutoIt functions FileOpen, FileWrite and FileClose to create a file. You will get all the HTML and none of the embedded content, but maybe it is sufficient...

Example without any error check:

$sHTML = _FFReadHTML("html", 6) ; the whole HTML 
$file = FileOpen($filename, 2) ; mode 2 = erase existing file
FileWrite($file, $txt)
FileClose($file)
Link to comment
Share on other sites

Hi, did u fix _FFLoadWait Function when using with socks or proxy

Sorry, I can't see a problem, I've tried some proxies on localhost, squid and wwwoffle in my network and some proxies in the internet, but I can't see any difference to a direct connection, only some speed differences.

_FFLoadWait uses the nsIWebProgress-interface from FireFox so why should there any difference between a proxy and a direct connection?

Link to comment
Share on other sites

<form method="POST" action="build.php">

<input type="hidden" name="id" value="25">
<input type="hidden" name="t" value="2">
<input type="hidden" name="a" value="4">
<table class="f10">
<tr>
<td>Offering</td>
<td><input class="fm" name="m1" value="" size="4"maxlength="6"></td>
<td>
<select name="rid1" size="" class="fm">
<option value="1" selected="selected">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>

</select>
</td>

How do i use _FFFormOptionselect to select the 2nd option?

Link to comment
Share on other sites

<form method="POST" action="build.php">

<input type="hidden" name="id" value="25">
<input type="hidden" name="t" value="2">
<input type="hidden" name="a" value="4">
<table class="f10">
<tr>
<td>Offering</td>
<td><input class="fm" name="m1" value="" size="4"maxlength="6"></td>
<td>
<select name="rid1" size="" class="fm">
<option value="1" selected="selected">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>

</select>
</td>

How do i use _FFFormOptionselect to select the 2nd option?

I think you'll need to use _FFXPath or if you know the form index then you can use _FFFormOptionselect() but I didn't test it with indexed form.

_FFXPath('//select[@name="rid1"]//option[@value="2"]', 'selected=true', 9)
Edited by Authenticity
Link to comment
Share on other sites

Posted Image

I get this error when trying to analyze http://facebook.com

Do you have always this error, if you trying it?

@JinQi:

_FFFormOptionselect($vElement = 0, $sElementMode = "index", $vOption = 0, $sOptionMode = "index", $vForm = 0, $sFormMode = "index")

e.g. for the second form:

_FFFormOptionselect("rid1", "name", 2, "value", 1)

or like Authenticity said via _FFXpath.

Edited by Stilgar
Link to comment
Share on other sites

Ya, everytime.

I can't reproduce that error on http://facebook.com.

Can you show me the output/console of the editor, please?

----

Update to V0.5.3.2:

- New: __FFDialogWait($sText[, $sTitle = ""[, $sClose = "close"[, $iTimeOut = 10000]]])

Waits for FireFox dialog messages (alert ...)

- Fixed: _FFConnect now returns an error if you try to connect to a non browser window (dialogs ..).

- Fixed: _FFSetValueById and _FFSetValueByName can now set unicode chars, too.

- Fixed: _FFCmd / _FFClick: fixed problems with element-names in arguments e.g:

_FFCmd(".ElementName.ElementName ....")

FF.au3

Edited by Stilgar
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...