Jump to content
FMS

IE - reading <div style=?>

Recommended Posts

FMS

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

Share this post


Link to post
Share on other sites
FrancescoDiMuro

Good morning @FMS:)
Have you already took a look about _IELoadWait() function? 

Best Regards,


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
FMS

@FrancescoDiMuro , Yes i did.
unfortunaly loadwait doesn't wait for the div to be 100% and the redirection occured :(


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@FMS
What object are you passing at the function _IELoadWait()? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
FMS

@FrancescoDiMuro _IELoadWait($IE_flvto)


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@FMS
From the Help file:

Quote

Parameters

$oObject : Object variable of an InternetExplorer.Application or DOM element

Why don't you try to pass the div object instead of the web page? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
FMS

@FrancescoDiMuro, I din't know we could do that. thanks for the pointer.

I must say I don't know how to do that.
Could you explain a little bit futher :)


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
FMS

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

Share this post


Link to post
Share on other sites
Juvigy

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")

Share this post


Link to post
Share on other sites
FMS
#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

Share this post


Link to post
Share on other sites
FrancescoDiMuro

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


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Danp2
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.

Share this post


Link to post
Share on other sites
FrancescoDiMuro
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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
FMS

@Danp2, @FrancescoDiMuro :wtf:I realy want to join this conversation and ask a smart question.......
but I realy don't understand what you are saying :D

 

So you are saying it isn't posible?
Or there is another way?


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
Danp2

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

 

Share this post


Link to post
Share on other sites
FMS

@Danp2 Nice this totaly works.
onostly I'm nut shure how :huh2:
Could you explaine a bit of your code ?
This so i understand and learn a bit more of (auto)it :)


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
Juvigy

@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

Share this post


Link to post
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

  • Similar Content

    • XaelloNegative
      By XaelloNegative
      Hi,
      So, I am trying to automate and simplify the retrieval of data from our company website (made by an outside company). I've had experience with IE manipulation via autoIt however, this one is a bit tricky for me.
      I have a table that has 81 cells which are buttons. What im trying to get is the information in "data-content" tag. 
      <a id="bookedVehicleLinkButton" class="btn btn-sm btn-block btn-xsm btn-success" data-toggle="popover" data-placement="bottom" data-original-title="Trip Details" data-container="body" data-content="Plate No: UGQ-857<br />Model: TOYOTA GRANDIA GL" href="javascript:__doPostBack('ctl00$ctl00$masterContentPlaceholder$reservationContentPlaceholder$bookingDataList$ctl00$vehicleDataList$ctl28$bookedVehicleLinkButton','')">IXARA (LITO SULIT)</a> Tried using the following:
      $oTagsCell = _IETagNameGetCollection($oIE, "td") For $item in $oTagsCell $test = _IEPropertyGet($item, "innertext") ClipPut($test) Next $oTagsTable = _IETagNameGetCollection($oIE, "table") For $item in $oTagsTable $test = _IEPropertyGet($item, "innertext") ClipPut($test) Next $oTagsLink = _IETagNameGetCollection($oIE, "a") For $item in $oTagsLink $test = _IEPropertyGet($item, "innertext") ClipPut($test) Next I don't receive any errors from my aforementioned attempts however no luck in getting those "data-contents". Attached is a screenshot, I do the looking of elements in chrome but the codes are for IE. And if you might ask, the cells (or buttons) have the same ID.
       
      Thank you guys for any inputs.
       
    • XinYoung
      By XinYoung
      Quick question: How can I click this "Select All" button in IE? There's no ID, and the href is "#"  
      Am I looking at the wrong html code?
      Am I looking
      Thank you all in advance!
    • Jemboy
      By Jemboy
      Hi,
      At work we have some proprietary website, users have to login to.
      I have "made" an autoit executable to start IE, go the website, login, so the user do not have input their credentials every time.
      By NDA I am not allowed disclosed the URL of the website nor the login credentials
      So I made a fake website and an autoitscript to illustrate my question.
      #include <ie.au3> $oIE = _IECreate ("about:blank", 0, 1, 1, 1) $HWND = _IEPropertyGet($oIE, "hwnd") WinActivate ($HWND,"") WinSetState($HWND, "", @SW_MAXIMIZE) _IENavigate ($oIE, "http://demo.rkilinc.nl",1) The above start my demo website. The actual website has some links in the footer that I do not want most people click on.
      I contacted the developers of the website and they are thinking of making an option to configure what links to show in the footer, but they said it's not a high priority for them.
       
      I discovered, that by click F12 and deleting the <footer> element the footer is delete from the live page view (until the page is reloaded off course)
      I want to automate the removal of the footer, without using things like send().
      I tried getting the footer with _IEGetObjById and deleting it with _IEAction, but that didn't work.
      Does any one has an idea how I could delete the footer directly from view with an autoit script?
      TIA, Jem.
       
       

    • XinYoung
      By XinYoung
      HI! ... this is a big one (at least for me) 
      You guys previously helped me copy the used range in column A and paste them into a Website one at a time in a loop. Cool! Now, for another function, I have 2 columns, A and B, and two input boxes in the Website. I'm having a hard time replicating the loop for the 2 columns. 
      This is how I'm opening the Excel workbook (copied from the previous function that only had 1 column). I need to also get the used range in column B.
      Func OpenExcelForCopy() Global $aBBTableData Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, $ChosenFileName, Default, True, True) $oExcel.Sheets("CopyCourses").Activate ;~ Get all used cells in column A:A Global $aSearchItems = _Excel_RangeRead($oWorkbook, 1, $oWorkbook.Sheets("CopyCourses").Usedrange.Columns("A:A")) ;~ Duplicate the $aSearchItems Array Global $aSearchResult = $aSearchItems ;~ Loop through the array starting at 0 until the end of the array which is (Ubound($aSearchItems) - 1) For $i = 0 To UBound($aSearchItems) - 1 $aSearchResult[$i] = SearchCourseForCopy($aSearchItems[$i]) Next _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") Finished() EndFunc ;==>OpenExcelForCopy Then we eventually get here. I don't think anything needs to change here but I'm not sure. This is where I paste the data from Column A into an input field (which is a search tool in a website). If the search is good, then we get to the tricky part...
      ;~ OK, we logged in and we searched for a course. Lets COPY it! Func CopyCourseBegin() Local $sResult $iSearchIndex = _ArraySearch($aBBTableData, "Course ID", 0, 0, 0, 1, 1, 0) ;~ If the course was not found, do this. If $iSearchIndex = -1 Then ;~ MsgBox(4096, "Search Error", "Item not found") $sResult = "Source Not Found" _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") ;~ Now go back to the Excel sheet and search for the next one. ;~ If the course was found, begin the COPY process. Else For $i = 0 To UBound($aSearchItems) - 1 $aSearchResult[$i] = CopyCourseNow($aSearchItems[$i]) Next $sResult = "Copied" _Excel_RangeWrite($oWorkbook, Default, $aSearchResult, "C1") EndIf Return $sResult EndFunc ;==>CopyCourseBegin This is the "tricky part" where I'm confused. I can copy and paste what's in column A just fine, but I can't manage to replicate it for column B. I need to paste whats in Column B into "destinationCourseId"
      ;~ The course search was successful. COPY the course now. Func CopyCourseNow($_sSearchResult) ;~ Navigate to the course copy page. _IENavigate($oIE, $urlBBCourseCopy) ;~ Copy the SOURCE course ID from the Excel sheet ;~ Paste whats copied from column A into the Source Course ID text box Local $oForm = _IEGetObjByName($oIE, "selectCourse") Local $oSearchString = _IEFormElementGetObjByName($oForm, "sourceCourseId") _IEFormElementSetValue($oSearchString, $_sSearchResult) ;~ Paste whats copied from column B into the Destination Course ID text box ?!?!?!?! Local $oForm = _IEGetObjByName($oIE, "selectCourse") Local $oSearchString = _IEFormElementGetObjByName($oForm, "destinationCourseId") _IEFormElementSetValue($oSearchString, $_sSearchResult) ;~ Just exit cause im stuck :( _Exit() EndFunc ;==>CopyCourseNow After I paste the data from column A into "sourceCourseId" and column B into "destinationCourseId", I'll make it do some stuff. Then I need it to loop around until the used ranges in column A & B is finished.
      Does the entire code need to change now that there's two columns?
       
       
    • Dequality
      By Dequality
      I don't really have any code cuz whatever i try it doesnt work -.- 
      Can anyone please make me a sample i can study? <,< i need to make a simple script to open explorer click some objects on the site , rinse repeat.. a example with autoit' website is just fine i just need to study it.. the i can't seem to find any yt video on this.. '-_-
      And yes i tried looking at the manual .. but i dont get anything from it <.<'
       
      Any help highly appreciatet <3 
×