Jump to content

IE - reading <div style=?>


 Share

Recommended Posts

Hello,

I'm trying to read a div element and wait until it hits 100%.
The structure is like :
<div class="progress-bar" style="width: 48.0219%;  overflow: hidden; "></div>

And want to wait until :
<div class="progress-bar" style="width: 100%;  overflow: hidden; "></div>

because afther this there will be an redirection whish i don't know the URL from and want to catsh this URL.
And want to push a button on this redidertion page.

Is there a best pratice way how to do this or is there a better way to wait for the redirection?
Maybe wait until button exist or something?

Does anybody could give me some tips about this challange?

 

thnx in advanced.

 

#include <IE.au3>

Global $IE_flvto = _IECreate("https://www.website.com/",0,1,1,1)
Global $oForm = _IEFormGetObjByName ($IE_flvto, "convertForm")
Global $oText = _IEFormElementGetObjByName ($oForm, "convertUrl")
_IEFormElementSetValue ($oText, "some text")
_IEFormSubmit($oForm)

;wait for redirection

;if redirection loaded push button

 

as finishing touch god created the dutch

Link to comment
Share on other sites

I'm a little stuck and maybe I'm thinking it totaly wrong.
could you look at this code ? :

#include <IE.au3>

Global $IE_flvto = _IECreate("https://www.website.com/",0,1,1,1)
Global $oForm = _IEFormGetObjByName ($IE_flvto, "convertForm")
Global $oText = _IEFormElementGetObjByName ($oForm, "convertUrl")
_IEFormElementSetValue ($oText, "sometext")
_IEFormSubmit($oForm)
Global $oDivp = _IEPropertyGet($IE_flvto, "progress-bar")
;~ Global $oDiv = _IEFormElementGetObjByName ($IE_flvto, "progress-bar")
Global $odiv = _IEPropertyGet ( $oDivp , "width" )

_IELoadWait($odiv)
ConsoleWrite("waited")


 

Edited by FMS

as finishing touch god created the dutch

Link to comment
Share on other sites

That wont work. Can you post the source-code of the page or the page itself ? You need to get an reference to the DIV element before you pass it to the IELOADWAIT function. You cant do it by _IEGetObjById or _IEGetObjByName or _IETagNameGetCollection. Check out the help files and examples.

You can also try passing the form object to the ieloadwait - not sure if it is going to work though.

Global $oForm = _IEFormGetObjByName ($IE_flvto, "convertForm")
Link to comment
Share on other sites

#include <IE.au3>

Global $IE_flvto = _IECreate("https://www.flvto.biz/",0,1,1,1)
Global $oForm = _IEFormGetObjByName ($IE_flvto, "convertForm")
Global $oText = _IEFormElementGetObjByName ($oForm, "convertUrl")
_IEFormElementSetValue ($oText, "https://www.youtube.com/watch?v=2H0yWKdZM8g")
_IEFormSubmit($oForm)

Global $oDivs = _IEGetObjByName($IE_flvto,"progress-bar")

;~ Global $oDivp = _IEPropertyGet($IE_flvto, "progress-bar")
;~ Global $oDiv = _IEFormElementGetObjByName ($IE_flvto, "progress-bar")
;~ Global $odiv = _IEPropertyGet ( $oDivp , "width" )
_IELoadWait($oForm)
ConsoleWrite("waited" & @CRLF )

 

Untitled.png

as finishing touch god created the dutch

Link to comment
Share on other sites

1 minute ago, FrancescoDiMuro said:

@Danp2
So the documentation has to be corrected :)
Always if it is what you are saying :)

No... id on't think so, unless I misunderstand what you're saying. The docs state the following --

Quote

When document objects or DOM elements are passed to _IELoadWait(), it will check the readyState of the container elements up to and including the parentWindow.

I think that some folks have a misconception that passing an element to _IELoadWait will result in the code waiting for that element to "finish loading", which isn't the case. If you examine the code, you will see that it identifies the type of object being passed in and uses that information to determine how to obtain it's containing document.

Link to comment
Share on other sites

3 minutes ago, Danp2 said:

I think that some folks have a misconception that passing an element to _IELoadWait will result in the code waiting for that element to "finish loading"

Without reading the Help file carefully, it is what you just described :D
 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@FMS
You are welcome :D
We are saying that, in the Help file, the _IELoadWait() functions seems that could be used for wait for a DOM Object too, but that's not what it is used for, since, if you look closer in the IE Library, you can see that the DOM Object is used for "arrive" at it's document, so, the load is always referred to the page, and not to the DOM Object :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Completely untested, but maybe you could do something like this --

Func _IERedirectWait(ByRef $oObject, $iDelay = 0, $iTimeout = -1)

    If Not IsObj($oObject) Then
        __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidDataType")
        Return SetError($_IESTATUS_InvalidDataType, 1, 0)
    EndIf

    If Not __IEIsObjType($oObject, "documentContainer") Then
        __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidObjectType")
        Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
    EndIf

    Local $sCurrentURL = _IEPropertyGet($oObject, "locationurl")
    Local $hIERedirectWait = TimerInit()
    Local $iError = $_IESTATUS_Success, $bAbort

    If $iTimeout = -1 Then $iTimeout = $__g_iIELoadWaitTimeout

    While Not (_IEPropertyGet($oObject, "locationurl") <> $sCurrentURL Or $bAbort)
        If (TimerDiff($hIERedirectWait) > $iTimeout) Then
            $iError = $_IESTATUS_LoadWaitTimeout
            $bAbort = True
        EndIf
        Sleep(100)
    WEnd

    Switch $iError
        Case $_IESTATUS_Success
            Return SetError($_IESTATUS_Success, 0, 1)
        Case $_IESTATUS_LoadWaitTimeout
            __IEConsoleWriteError("Warning", "_IERedirectWait", "$_IESTATUS_LoadWaitTimeout")
            Return SetError($_IESTATUS_LoadWaitTimeout, 3, 0)
    EndSwitch
EndFunc

 

Link to comment
Share on other sites

@Danp2, smart workaround.

@FMS, What the code does is basically wait until the location URL changes. This is the main script idea:

While Not (_IEPropertyGet($oObject, "locationurl") <> $sCurrentURL Or $bAbort)

I was going to go for getting the DIV element and reading its properties to see when it finishes, but this way is faster and more simple.

Edited by Juvigy
NA
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

×
×
  • Create New...