Jump to content
Sign in to follow this  

[BUG] ?? $oTag.GetAttribute doesn't give expected results afther $oIE.GoBack

Recommended Posts


I try to get all the text from a news site around a subject.
The first run I get all the text inside a attribute in an array.
When i try to go back and reload another page it chrashes and think it because "$oIE.GoBack"
I couldn't find anything in the help/forum around this subject.
Do I need to reload the $oIE or something afther an X.GoBack?

The error i got is :

if $oTag2.GetAttribute("class") == "NewsDetail" Then
if $oTag2^ ERROR

I'm not shure why I got this error, maybe someone could explain?
Also I'm open for some pointers in this test script because I'm pretty new in working whit the IE.UDF :)
Maybe there is an simpler way to get the same results?

test script:

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

HotKeySet("{ESC}", "Terminate")

Global $oIE = _IECreate("https://www.iex.nl/Zoeken/Nieuws.aspx?q=air%20france")

;get first subject
Global $oLink1 = _IEGetObjById($oIE, "ctl00_ctl00_Content_LeftContent_NewsSearch_repNews_ctl00_linkNews")
_IEAction($oLink1, "click")
Global $oTags = _IETagNameGetCollection($oIE, "div")
Global $aResults[1]
For $oTag In $oTags
    if $oTag.GetAttribute("class") == "NewsDetail" Then
        _ArrayAdd($aResults, $oTag.innerTEXT)
 $aResults[0] = UBound($aResults) - 1
 _ArrayDisplay($aResults, "Episodelist")
 ConsoleWrite($aResults[1] & @CRLF)

;get second subject
Global $oLink2 = _IEGetObjById($oIE, "ctl00_ctl00_Content_LeftContent_NewsSearch_repNews_ctl01_linkNews")
_IEAction($oLink2, "click")
Local $oTags2 = _IETagNameGetCollection($oIE, "div")
Local $aResults2[1]
For $oTag2 In $oTags2
    if $oTag2.GetAttribute("class") == "NewsDetail" Then
        _ArrayAdd($aResults2, $oTag2.innerTEXT)
 $aResults2[0] = UBound($aResults2) - 1
 ConsoleWrite($aResults2[1] & @CRLF)

Func Terminate()
EndFunc   ;==>Terminate


Edited by FMS

as finishing touch god created the dutch

Share this post

Link to post
Share on other sites

You don't get the class via an attribute...you get it via a property:

$sClass = $oTag2.className()
consolewrite($sClass & @crlf)

Also.  if you are going to navigate away from the page, you need to store the value prior to navigating.

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.

Share this post

Link to post
Share on other sites

thanks for the tips, I've solved it like this :

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

HotKeySet("{ESC}", "Terminate")

;~ Global $aResults[1]
;~ Global $aDates[1]

Global $results[1][3] = [["date","rate","text"]]

_ArrayDisplay($results, "$results" )

Func fetch_text($article_count = 1 )
   Local $temp_ar[1][3]
   Local $LinkObj
   Local $DateObj
   Local $Date
   Local $Tags
   $sleeptimer = 400
   Local $IE = _IECreate("https://www.iex.nl/Zoeken/Nieuws.aspx?q=air%20france",0,0,1,1)
   Sleep( $sleeptimer )

   for $x = 0 to $article_count - 1
      $LinkObj = _IEGetObjById( $IE , "ctl00_ctl00_Content_LeftContent_NewsSearch_repNews_ctl0" & $x & "_linkNews")
      $DateObj =_IEGetObjById( $IE , "ctl00_ctl00_Content_LeftContent_NewsSearch_repNews_ctl0" & $x & "_Label1")
      $Date = _IEPropertyGet ( $DateObj , "innertext")
      $temp_ar[0][0] = $Date
      $temp_ar[0][1] = 0
      _IEAction($LinkObj, "click")
      Sleep( $sleeptimer )
      $Tags = _IETagNameGetCollection($IE, "div")

      For $Tag In $Tags
         if Execute('$Tag.GetAttribute("class")') == "NewsDetail" Then
            $temp_ar[0][2] = $Tag.innerTEXT
      _ArrayAdd($results, $temp_ar )
      Sleep( $sleeptimer )



Edited by FMS
code edit

as finishing touch god created the dutch

Share this post

Link to post
Share on other sites

Strangly enough the code above give's strange results but don't know what it is.
once in a while I get the folowing error, does anybody know why I get it?
Is it the code or is it a feature :D

==> The requested action with this object has failed.:


as finishing touch god created the dutch

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By devilspride
      The following code creates a IE blank window
      Local $oIE = _IECreate()  
      But when i use Navigate to the URL, it open the URL in Microsoft Edge instead if IE.
      What should i do to navigate in IE.
      Complete code :
      #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <IE.au3> #Region TESTING Local $url = 'https://www.youtube.com' Local $oIE = _IECreate() _IENavigate($oIE,$url) #EndRegion Console Output
      IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023174, Browser has been deleted prior to operation.)  
      I have searched the forums but did not find such kind of post.
      Other posts were describing How to use Edge using Web driver selenium.
      Edit: I am working in Windows10. Recently many changes have been done by Microsoft to IE and Microsoft Edge. (2020)
      Earlier in 2019 this was working fine.
    • By Zaoka
      I'm trying to create script that would login on my SAP WEBI "web page" and replace some uploaded excel files. But i'm having problem on even the log in.
      These are user fill elements with Firefox Inspector
      <input type="text" id="_id0:logon:CMS" name="_id0:logon:CMS"> <input type="text" id="_id0:logon:USERNAME" name="_id0:logon:USERNAME"> <input type="password" id="_id0:logon:PASSWORD" name="_id0:logon:PASSWORD"> LogOnButton
      <input type="submit" id="_id0:logon:logonButton" value="Log On" class="logonButtonNoHover logon_button_no_hover" onmouseover="this.className = 'logonButtonHover logon_button_hover';" onmouseout="this.className = 'logonButtonNoHover logon_button_no_hover';">  
      My example, I tried _IEGetObjByName and _IEGetObjById but the script only open page but will not even fill out the form
        #include <IE.au3> Call("signIn") Func signIn() Global $oIE = _IECreate("http://192.xxx.xxx.xx:xxx/BOE/BI") Sleep (5000) Local $server = _IEGetObjByName($oIE, "_id0:logon:CMS") Local $username = _IEGetObjByName($oIE, "_id0:logon:USERNAME") Local $password = _IEGetObjByName($oIE, "_id0:logon:PASSWORD") Local $button = _IEGetObjById($oIE, "_id0:logon:logonButton") _IEFormElementSetValue($server, "TestServer:1000") _IEFormElementSetValue($username, "MyUserName") _IEFormElementSetValue($password, "MyPass") ; THIS PART ABOUT BUTTON CLICK I DONT UNDERSTAND AT ALL $sSelector = "body > div:nth-of-type(2) > div > div:nth-of-type(3) > div > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr:nth-of-type(1) > td > div > div:nth-of-type(1) > form > div:nth-of-type(5) > button" $signInUC = $oIE.document.QuerySelector($sSelector) _IEAction($signInUC, "click") EndFunc ;==>signIn  
      I would be very grateful for any help
    • By adityaparakh
      Hello ,

      A website I am trying to login with my credentials.
      And retrieve the cookie into a text file.
      Unable to do so.
      Is it that certain,  Httponly , type - are not allowed to be fetched.

      Then further ,
      I will be checking every 5 minutes if my session is active , else re-login and re-fetch the cookie.
      For the second part , I will probably fetch some table and see if not in appropriate format do Part 1 : Fetch Cookie - again.
      Any better way , tips would be appreciated.
    • By Jamestay97
      Hello! Thanks you for looking at my post
      **No source code I'm sorry work related can't copy information**
      I've been using autoit for about 1 year. 
      I'm having trouble automating a click on an internet explorer web page and I've tried a lot of examples from help pages and forums already. The object I'm trying to click on isnt always in the same spot so I can't use mouse click or control click, I have tried to use the different get collection options and clickbyname, or index or get object. I'm just struggling. 
      Description of object I'm trying to click -- 
      HTML Code looks like <a ng-click.. "Click Here" it appears it's just a click able object named "click here" that opens a hidden window by running a script inside the web page. I'm not able to grab the information from the window unless it's open so I have to automate this click somehow. 
      I understand it's difficult to assist without having something to look at, I apologize for that sincerely and appreciate and assistance and suggestions. 
    • By FUD
      please i need help 
      i need to open link in default browser only one windows without duplicate if i try to open the same link 
  • Create New...