Barfly Posted March 27, 2007 Posted March 27, 2007 Hi I do not know if I am being particularly stupid this morning??? I am trying to write some test scripts that test a web application. I have used Autoit in the past to test basic Windows apps, but never on the web. I would like to be able to specify a tag id, name or index; then I would like to read the inner text of that object. I can 'grab' the object but do not seem to be able to read the text. Is the ReadHTMl or BodyText the only commands to read text in IE in Autoit?? Help would be fantastic thanks!!
DaleHohm Posted March 27, 2007 Posted March 27, 2007 There is lots of support for this in IE.au3 - see IE Management in the UDF section of the helpfile. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
Barfly Posted March 27, 2007 Author Posted March 27, 2007 There is lots of support for this in IE.au3 - see IE Management in the UDF section of the helpfile. Dale I have read through all the descriptions in the help file. There does not seem to be a function that reads the text within a tag. Sort of being able to drill down within the HTML to locate an exact tag that may or may not have an id or name specified. For example: oIE = _IECreate ($Environment) ;__________rc_readtext__________ ;(1) The name of the id of the div that holds the tag that the text appears in. (2) The tag name that it appears in (eg: <td>, <span> or <a>. (3) The index number of the tag (within the div) ; (1) $rc_readtext_divid : Foo ; (2) $rc_readtext_TagName : Foo ; (2) $rc_readtext_TagNumber : # ;___________________________________________________________________________________________________ _______________________________________________________ Func rc_readtext($rc_readtext_idName, $rc_readtext_idNumber) $oDiv = _IEGetObjByName ($oIE, $rc_readtext_divid) $oTag = _IEGetObjByName ($oDiv, $rc_readtext_TagName, $rc_readtext_TagNumber) $oText = ReadText($oTag) return $oText EndFunc I have obviously used some artistic licence, to explain how my mind is working with this. Could you point me in the right direction? Thanks in advance :-)
DaleHohm Posted March 27, 2007 Posted March 27, 2007 See _IEPropertyGet $sText = _IEPropertyGet($oTag, "innerText") Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
Barfly Posted March 27, 2007 Author Posted March 27, 2007 See _IEPropertyGet $sText = _IEPropertyGet($oTag, "innerText")DaleOK, that makes sense! Thanks! I was just unaware that you could specify "innerText"......just another quick question....I am using _IETagNameGetCollection ($oDiv, "span", 0) to get to the tag that I want to look at as the one I want does not have an id or name associated with it. I just do not understand how to read the 'indexed instance' or 'object collection'. Is this like an array? If so, how can I read teh returned results?
DaleHohm Posted March 27, 2007 Posted March 27, 2007 OK, that makes sense! Thanks! I was just unaware that you could specify "innerText". .....just another quick question....I am using _IETagNameGetCollection ($oDiv, "span", 0) to get to the tag that I want to look at as the one I want does not have an id or name associated with it. I just do not understand how to read the 'indexed instance' or 'object collection'. Is this like an array? If so, how can I read teh returned results?_IETagNameGetCollection ($oDiv, "span", 0) will return a single-object variable with the first match (,1 the second - ,2 the third etc) _IETagNameGetCollection ($oDiv, "span") will return an object collection of all matches -- @extended gives you the match count loop through a collection like this: $oSpans = _IETagNameGetCollection ($oDiv, "span") For $oSpan in $oSpans ConsoleWrite(_IEPropertyGet($oSpan, "innerText") & @CR "--------------" & @CR) Next A collection is not an array, but shares some things conceptually with arrays. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now