Ebola57 Posted February 5, 2020 Share Posted February 5, 2020 (edited) Hi community I rewrote my problem for a better understanding and posted scripts that I allready tried To sum up, I am able to do what I want on this page (ie : write in input, wait for the search engine result, click on button aso..., BUT not open combo box nor validate typed text And this part is VERY important to me as I need t hide the browser (If visible I can manage this with Send () or ControlSend () ) expandcollapse popupLocal $hIE = WinGetHandle ( "[CLASS:IEFrame]", {confidential} ) Local $oIE = _IEAttach( $hIE, "hwnd" ) Local $oDoc = _IEDocGetObj ( $oIE ) Local $sTagName = "select" Local $sAttr1 = "name" Local $sVal1 = "nature_du_stock_matriel_00" Local $sNat = "ENEDIS" Local $oItems ; Doesn't work Local $oTagCollection = $oDoc.GetElementsByTagName ( $sTagName ) For $oTag In $oTagCollection If StringInStr ( $oTag.GetAttribute ( $sAttr1 ), $sVal1 ) > 0 Then Local $oItems = $oTag.Options For $oItem In $oItems If $oItem.Value == $sNat Then $oItem.Selected = True $oItem.FireEvent ( "OnChange" ) $oItem.FireEvent ( "OnClick" ) ExitLoop EndIf Next ;EndIf EndIf Next Local $sTagName = "input" Local $sAttr1 = "aria-label" Local $sVal1 = "Nature du stock matériel" Local $sNat = "ENEDIS" ; Partial work, as shown in picture, but not what I need ( combobox opened, values validated ) Local $oTagCollection = $oDoc.GetElementsByTagName ( $sTagName ) For $oTag In $oTagCollection If StringInStr ( $oTag.GetAttribute ( $sAttr1 ), $sVal1 ) > 0 Then $oTag.Focus ( ) ; Works, as shown in picture $oTag.Click ( ) ; Does nothing on ALL tags EndIf Next ; Nothing happens, tried an ALL tags Local $oTagCollection = $oDoc.GetElementsByTagName ( $sTagName ) For $oTag In $oTagCollection If StringInStr ( $oTag.GetAttribute ( $sAttr1 ), $sVal1 ) > 0 Then $oTag.Click $oTag.FireEvent ( "OnChange" ) $oTag.FireEvent ( "OnClick" ) EndIf Next Got this in mind as a way of solution but don't really what to typas as "node" $oTag.FireEvent.KeyDown ( {DOMnode}, "{ key: 'Enter', code: 13 }" ) Also noticed that IE >= 9 may have differnte way of managing [ENTER] keypress as said here https://stackoverflow.com/questions/9714527/why-does-fireevent-not-work-in-ie9 But I wasn't able yet to translate it in autoit script Tried this, with no effect, either on <a> tag or <input> Local $oEvent = $oDoc.CreateEvent ( "HTMLEvents" ) $oEvent.InitEvent ( "change", True, False ) $oTag.DispatchEvent ( $oEvent ) Below the HTML source of the incriminated part Any help, way of search or solution would be highly appreciated, as I am really stuck on this problem Regards Edited February 7, 2020 by Ebola57 Link to comment Share on other sites More sharing options...
Nine Posted February 5, 2020 Share Posted February 5, 2020 Seems to me you are trying to interact with a combo-box ? If so, have you look at _IEFormElementOptionSelect function ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Ebola57 Posted February 5, 2020 Author Share Posted February 5, 2020 Indeed, but I forgot this way, as I was unable to catch the id / tag of the form Since then I wrote a function that catch the "form" by attribute + propertie, going to try the "right" way again As information this web page is taken from a ServiceNOW instance customized for my firm Here the code displaying the form tag Going to try again with your way and be back Link to comment Share on other sites More sharing options...
Ebola57 Posted February 5, 2020 Author Share Posted February 5, 2020 (edited) This code leads me to the result captured in screenshot $hIE = WinGetHandle ( "[CLASS:IEFrame]","" ) WinActivate ( $hIE ) $oIE = _IEAttach( $hIE, "hwnd" ) Local $aForm = _IEGetObjBy2AttributesAnd2Values ( $oIE, "form", "class", "ng-pristine ng-valid ng-valid-maxlength", "role", "form", 5000 ) Local $oSelect = _IEFormElementGetObjByName($aForm [0], "unite_d_oeuvre_00") _IEAction ( $oSelect, "focus" ) _IEFormElementOptionSelect ( $oSelect, "CNIP-A03 : Remplacement poste de travail", 1, "byText" ) _IEGetObjBy2AttributesAnd2Values is a custom function that catch the form object when it has neither id nor name, 5000 is a timeout value The box is selected, but doesn't scroll or select any item :/ the ending point is still the same, i can't interract with such combo box without having to send a ControlSend command, that I'd like to get rid off Edited February 5, 2020 by Ebola57 Link to comment Share on other sites More sharing options...
Ebola57 Posted February 7, 2020 Author Share Posted February 7, 2020 I rewrote first topic to be clearer and gave what scripts I allready tried Link to comment Share on other sites More sharing options...
Danp2 Posted February 7, 2020 Share Posted February 7, 2020 Can you run the following in Scite and show us the results from the Output panel? $hIE = WinGetHandle ( "[CLASS:IEFrame]","" ) $oIE = _IEAttach( $hIE, "hwnd" ) Local $aForm = _IEGetObjBy2AttributesAnd2Values ( $oIE, "form", "class", "ng-pristine ng-valid ng-valid-maxlength", "role", "form", 5000 ) Local $oSelect = _IEFormElementGetObjByName($aForm[0], "nature_du_stock_matriel_00") _IEFormElementOptionSelect( $oSelect, "ENEDIS") _IEFormElementOptionSelect( $oSelect, "GRDF", 1, "byText") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Ebola57 Posted February 7, 2020 Author Share Posted February 7, 2020 Sure ! but ... As this unoptimised function is no more, rewrote some code that should do equivalent to your code (if I am right) #include <IE.au3> Local $hIE = WinGetHandle ( "[CLASS:IEFrame]", "MyUrl" ) WinActivate ( $hIE ) Local $oIE = _IEAttach( $hIE, "hwnd" ) Local $oDoc = _IEDocGetObj ( $oIE ) Local $oForm = _IEFormGetObjCustomWay ( $oDoc ) Local $oSelect = _IEGetObjByName ( $oForm, "nature_du_stock_matriel_00" ) _IEFormElementOptionSelect( $oSelect, "ENEDIS") _IEFormElementOptionSelect( $oSelect, "GRDF", 1, "byText") Func _IEFormGetObjCustomWay ( $oDoc ) Local $oForms = $oDoc.GetElementsByTagName ( "form" ) If IsObj ( $oForms ) Then For $Form In $oForms If $Form.GetAttribute ( "class" ) == "ng-pristine ng-valid ng-valid-maxlength" And $Form.GetAttribute ( "role" ) == "form" Then Return SetError (0 ,0, $Form ) EndIf Next Else Return SetError (1 ,0, "Not a form collection" ) EndIf EndFunc Such code does nothing in my IE session and here's Scite output >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\path\Tests autoit forum.au3" /UserParams +>17:40:00 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0 Keyboard:0000040C OS:WIN_81/ CPU:X64 OS:X64 Environment(Language:040C) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper >Running AU3Check (3.3.14.5) from:C:\path\Tests autoit forum.au3 +>17:40:00 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files (x86)\path\Tests autoit forum.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop +>17:40:01 AutoIt3.exe ended.rc:0 +>17:40:01 AutoIt3Wrapper Finished. >Exit code: 0 Time: 1.156 Link to comment Share on other sites More sharing options...
Danp2 Posted February 7, 2020 Share Posted February 7, 2020 Ok... so no errors from either call to _IEFormElementOptionSelect. If there still wasn't a selection made by either command, then I'm not sure how we can assist further unless you can find a publicly accessible website that exhibits the same symptoms. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted February 7, 2020 Share Posted February 7, 2020 (edited) "nature_du_stock_matriel_00" there is a fault in there. Shouldn't that be ""nature_du_stock_matériel_00" ? nvm misread it :/ Edited February 7, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Ebola57 Posted February 7, 2020 Author Share Posted February 7, 2020 I never had such symptoms, but in this case, the HTML is somehow heavy and complex What I learnt is there's some Javascript from an Angular Framework On other combo box, when 'click' or 'Eneter' is pressed it générates a serach engine where i ahve to pick up the value that fills then the input box Got the same problem on this item, everything is possible but not 'Enter' nor 'click' Link to comment Share on other sites More sharing options...
Ebola57 Posted February 7, 2020 Author Share Posted February 7, 2020 3 minutes ago, Nine said: "nature_du_stock_matriel_00" there is a fault in there. Shouldn't that be ""nature_du_stock_matériel_00" ? nvm misread it :/ Indeed, in French (native language) it should be 'materiel', but there's an "official" typo error Inside the code ... 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