kistoff Posted October 27, 2012 Share Posted October 27, 2012 (edited) I can not figure out how to get the text from a box that pops up in the form after hitting a button. Button <button style="white-space: nowrap;" id="auto_assign_3" class="form_action_button header action_context" title="Auto Assign" onclick="getAutoAssignment();;return false;" type="submit" value="cfc23c1cbda36000947b7b26545cb012" gsft_id="cfc23c1cbda36000947b7b26545cb012"><span>Auto-assign</span></button> Three possible text blocks will display. I would like to get "No auto-assignment group found." from this. <div class="outputmsg outputmsg_error"> <img class="outputmsg_image" src="images/outputmsg_error_24.gifx">No auto-assignment group found.</div> "Auto-assignment successful." from here. <div class="outputmsg outputmsg_info"> <img class="outputmsg_image" src="images/outputmsg_info_24.gifx">Auto-assignment successful.</div> "Multiple auto-assignment groups found." from here. <div class="outputmsg outputmsg_info"> <img class="outputmsg_image" src="images/outputmsg_info_24.gifx">Multiple auto-assignment groups found.</div> I have tried to use _IEImgGetCollection, _IELinkGetCollection, _IETagNameAllGetCollection, _IETagNameGetCollection, _IEGetObjById, _IEGetObjByName. Can someone point me in the right direction? Edited October 29, 2012 by kistoff Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 27, 2012 Share Posted October 27, 2012 (edited) for applying data to elements having a common classname use the classname property like if $oImg.classname='outputmsg_image' then ; so and so.. Edited October 27, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
kistoff Posted October 27, 2012 Author Share Posted October 27, 2012 (edited) If I try that $oIE = _IEAttach ; url here $oImg = _IEImgGetCollection($oIE, "outputmsg_image") $sInfo = $oImg.classname MsgBox(0, "", $sInfo) I get - "outputmsg_close" Maybe I didn't list the right code. <div id="output_messages" class="outputmsg_container"> <img class="outputmsg_close" onclick="GlideUI.get().clearOutputMessages(this)" alt="Close Messages" src="images/x.gifx"> <div class="outputmsg_div"> <div class="outputmsg outputmsg_error"> <img class="outputmsg_image" src="images/outputmsg_error_24.gifx">No auto-assignment group found.</div> <div class="outputmsg outputmsg_info"> <img class="outputmsg_image" src="images/outputmsg_info_24.gifx">Auto-assignment successful.</div> <div class="outputmsg outputmsg_info"> <img class="outputmsg_image" src="images/outputmsg_info_24.gifx">Multiple auto-assignment groups found.</div> </div></div> Edited October 29, 2012 by kistoff Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 27, 2012 Share Posted October 27, 2012 you used wrong parameter in the second part [i.e. the index] this code should work [taken from the help file] #include <IE.au3> $oIE = _IECreate("http://www.autoitscript.com/") Local $oImgs = _IEImgGetCollection($oIE) Local $iNumImg = @extended MsgBox(0, "Img Info", "There are " & $iNumImg & " images on the page") For $oImg In $oImgs MsgBox(0, "Img Info", "class=" & $oImg.classname) Next My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
kistoff Posted October 27, 2012 Author Share Posted October 27, 2012 Ah you are right, its been a long day and I am learning as I go.If I run that code with only changing the URL. It tells me there are 26 images on the page, class=outputmsg_close followed by class=0 26 times. Link to comment Share on other sites More sharing options...
kistoff Posted October 29, 2012 Author Share Posted October 29, 2012 I have been searching the forums for more solutions, but have come up with nothing so far. Anyone have some more ideas on what I can try? Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 30, 2012 Share Posted October 30, 2012 could you give the URL of the webpage? it would be a lot easier to help then My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted October 30, 2012 Share Posted October 30, 2012 @kistoff - you could use the _INetGetSource and _StringBetween functions. Here's a short example with just _StringBetween(). #include <String.au3> $sString = '<img class="outputmsg_image" src="images/outputmsg_error_24.gifx">No auto-assignment group found.</div>' $aString = _StringBetween($sString, 'outputmsg_error_24.gifx">', '</div>') MsgBox(0, '', $aString[0]) - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
kistoff Posted October 30, 2012 Author Share Posted October 30, 2012 (edited) @PhoenixXL - thanks for the help!It is an internal work website, so I can not give out the URL. It is for service-now and there is a demo version on the web (https://demo03.service-now.com/navpage.do), but it may not have the field I am trying to get unless someone has modified it (I could play with the admin side and try to find the setting for it). Demo03 actually has the box atm, but I am not sure when the server gets reset. Login with "ITIL, ITIL" and click on an incident "INC000000" and It is the box "Done done done".@somdcomputerguy - I will look into that in the morning, thanks! Edited October 30, 2012 by kistoff Link to comment Share on other sites More sharing options...
kistoff Posted October 30, 2012 Author Share Posted October 30, 2012 Well that code worked thanks! I Would never have thought to use _Stringbetween. #include <String.au3> $sString = '<img class="outputmsg_image" src="images/outputmsg_error_24.gifx">No auto-assignment group found.</div>' $aString = _StringBetween($sString, 'outputmsg_error_24.gifx">', '</div>') MsgBox(0, '', $aString[0]) Link to comment Share on other sites More sharing options...
jdelaney Posted October 30, 2012 Share Posted October 30, 2012 (edited) I would avoid stringbetween to get html node objects...my signature has a udf to use XPath's instead (not all valid xpaths are covered). So, you can do something like this, as an example #include "C:AutomationEFLBrowser_Generic.au3" #include <IE.au3> #include <Array.au3> $oIE = _IECreate ("www.msn.com", True, True ) ; example of getting both 'Maps' links $aoMapLinks = BGe_IEGetDOMObjByXPathWithAttributes ( $oIE, "//a[contains(@href,'bing.com/maps/')]") _ArrayDisplay ( $aoMapLinks ) ; or, by the value: $aoMapLinks = BGe_IEGetDOMObjByXPathWithAttributes ( $oIE, "//a[.='Maps']") _ArrayDisplay ( $aoMapLinks ) ; or, just the link that's inside a certain node: $aoMapLinks = BGe_IEGetDOMObjByXPathWithAttributes ( $oIE, "//form[@class='skipOOB']//a[.='Maps']") _ArrayDisplay ( $aoMapLinks ) array data returned are objects, so you can do any IEAction on them Edited October 30, 2012 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. Link to comment Share on other sites More sharing options...
kistoff Posted October 30, 2012 Author Share Posted October 30, 2012 I am rather new at this and I am not familiar with XPath, so I am not sure what syntax to use in order to find something in a document. I will do some reading about that, know of a good resource? If I run the code it returns.. Row Col 0 [0] [1] Should it show more or am I missing something? Link to comment Share on other sites More sharing options...
Tjalve Posted October 31, 2012 Share Posted October 31, 2012 (edited) Cant you use regex? Like this:#include <array.au3> $array = StringRegExp("<img class=""outputmsg_image"" src=""images/outputmsg_error_24.gifx"">No auto-assignment group found.</div>","<img class=""outputmsg_image"" src=""images/outputmsg_error_24.gifx"">(.*?)</div>",3) _arraydisplay($array) Edited October 31, 2012 by Tjalve Link to comment Share on other sites More sharing options...
jdelaney Posted October 31, 2012 Share Posted October 31, 2012 (edited) w3schools ftw:http://www.w3schools.com/xpath/xpath_intro.aspThe array data is expected to be empty, they are objects.Reworking to use your site#include "C:AutomationEFLBrowser_Generic.au3" #include <IE.au3> #include <Array.au3> $oIE = _IECreate ("https://demo03.service.now.com/navpage.do", True, True ) _IELoadWait ( $oIE ) ; example of getting both 'Maps' links $aoImages = BGe_IEGetDOMObjByXPathWithAttributes ( $oIE, "//img[@class='outputmsg_image'") ;_ArrayDisplay ( $aoMapLinks ) For $i = 0 To UBound ( $aoImages) -1 $oNode = $aaoImages[$i] ConsoleWrite ( $oNode.innertext & @crlf ) Next Edited October 31, 2012 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. Link to comment Share on other sites More sharing options...
kistoff Posted November 1, 2012 Author Share Posted November 1, 2012 (edited) @Tjalve - That did work, thanks!@jdelaney - I have been tinkering with this off and on all day. I think I have finally figured it out after trying a bunch of things and reading up on Xpath. Thanks for the link to w3schools and thanks for the help!Here is what I came up with.#include <IEGetDOMObjByXPathWithAttributes.au3> #include <IE.au3> #include <Array.au3> $oIE = _IEAttach("...", "URL") $oFrame = _IEFrameGetCollection($oIE, 1) $aoImages = BGe_IEGetDOMObjByXPathWithAttributes($oFrame, "//div[@class='outputmsg outputmsg_error']") For $i = 0 To UBound ($aoImages) -1 $oNode = $aoImages[$i] ConsoleWrite($oNode.innertext & @crlf )This writes to the console.No auto-assignment group found. Edited November 1, 2012 by kistoff Link to comment Share on other sites More sharing options...
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