Jump to content

Recommended Posts

Posted

I'm trying to click on specific "hidden" fields on a web page and I've installed debugbar (as per Click a button in a webpage - Started by Mithrandir, February 15, 2010 ) to narrow it down but I'm not quite sure how to convert the info from debugbar to the appropriate IE calls.  I just want to click here and then enter in some data.

Document
 HTML
   BODY
    Div class=urlconverter
      DIV id=stepConvert
        DIV class=urlconverter-section-1
          DIV class=container
            DIV class=urlconverter-section-left-1
              DIV class=class=container
                DIV class=urlconverter-section-1-1
                  DIV class=row
                    DIV class=col-sm-12
                      UL class=urlconverted-section=1=1=form
                        LI
                          INPUT id=target
Posted

Try something like this:

#include <IE.au3>

Local $oIE = _IECreate('http://yui.github.io/yui2/docs/yui_2.9.0_full/examples/button/btn_example05.html', 1)
Local $oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
    If $oInput.id = "firstname" Then _IEFormElementSetValue($oInput, "John")
    If $oInput.id = "lastname" Then _IEFormElementSetValue($oInput, "Doe")
Next

 

Posted

There are 50 items that match that and many of them have blank .ids.  I can never know I am at the one I need.  Now, I kind of have it working with this:

$colLinks = _IETagNameGetCollection($oIE, 'div')
    For $oLink In $colLinks
        If $oLink.className() = 'urlconverter-section-1-title' Then
            $x = _IEPropertyGet($oLink, 'screenx')
            $y = _IEPropertyGet($oLink, 'screeny')
            writelog($x,$y)
            MouseClick("",$x+20,$y+50)
            Send($url)
            Sleep(2000)
            Send("{ENTER}")
        EndIf
    Next

but, admittedly, it is rather crude and prone to error.

 

ps ;) I haven't even gotten to the "hard" part yet!

Posted

Did you try my example?  I'm not sure why you're targeting a div rather than an Input button, each button has to have a unique id/name.  Do you have a URL that we can test?

Posted
2 hours ago, jaja714 said:

There are 50 items that match that and many of them have blank .ids.  I can never know I am at the one I need.

yes, I tried your example.

Posted
#include <IE.au3>

Local $oIE = _IECreate('https://www.onlinevideoconverter.com/video-converter', 1)
;~ Add URL
Local $oInputs = _IETagNameGetCollection($oIE, 'input')
For $oInput In $oInputs
    If $oInput.id = 'texturl' Then _IEFormElementSetValue($oInput, 'https://www.youtube.com/watch?v=uMK0prafzw0')
Next
;~ Click Start Button
Local $oInputs = _IETagNameGetCollection($oIE, 'a')
For $oInput In $oInputs
    If $oInput.id = 'convert1' Then _IEAction($oInput, 'Click')
Next

 

Posted (edited)

You can use my signature to return an array of matching dom objects based on a xpath...if you find that the _IE functions to get specific enough to find your object.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted (edited)

Ah, thanks to both jd and Subz (and Dale Holm too) for the info as I was able to make quite a bit of progress here.  I have a skeleton working but I have a sleep statement I'd like to replace.

So, when I call _IECreate, _IELoadWait is implied.  However, when I click on a button that loads a new page or redirects to another url, how do I "wait" for that task to complete before proceeding with my next step?  I tried putting _IELoadWait but that doesn't work.  If I don't put that SLEEP statement in there, the whole script fails later with "The requested action with this object has failed" on the $oInput.href reference.  Even with the SLEEP statement, I get the occasional "The requested action with this object has failed" but I'm sure increasing the SLEEP time will solve that.

Before I do that ... how can I code so that I don't have to rely on that SLEEP statement?

Func dl($url,$dest)

    _IEErrorNotify(True)
    writelog($url,$dest)
    If FileExists($dest) Then Return

    $oIE = _IECreate('https://www.onlinevideoconverter.com/video-converter')

    ;~ Add URL
    $oInputs = _IETagNameGetCollection($oIE, 'input')
    For $oInput In $oInputs
        If $oInput.id = 'texturl' Then
            _IEFormElementSetValue($oInput, $url)
        EndIf
    Next
    Sleep(2000)

    ;~ Click Start Button
    $oInputs = _IETagNameGetCollection($oIE, 'a')
    For $oInput In $oInputs
;        writelog('id',$oInput.id)
        If $oInput.id = 'convert1' Then
            _IEAction($oInput, 'Click')
            _IELoadWait($oIE)
        EndIf
    Next
    SLEEP(10000)

    While True
        ;~ Download file
        $oInputs = _IETagNameGetCollection($oIE, 'a')
        If @error = 0 Then
            If IsObj($oInput) Then
                For $oInput In $oInputs
                    writelog('ID',$oInput.ID)
                    If StringInStr($oInput.href,'onlinevideoconverter.com/download?file=') Then
                        InetGet($oInput.href, $dest,0,1)
                        _IEQuit($oIE)
                        Return
                    EndIf
                Next
            EndIf
        Else
            writelog('@error',@error)
        EndIf
        sleep(500)
    WEnd

EndFunc

 

Edited by jaja714
Posted

What I have found is try and use IECreate with attach or IEAttach so it doesn't create new instances helps.  You could use something like

While _IEPropertyGet($oIE, 'Busy')
    Sleep(50)
Wend

Or look for something else on the page in the page properties to see when to move to the next action.

Hope that helps.

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
  • Recently Browsing   0 members

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