MeAgain Posted February 11, 2016 Share Posted February 11, 2016 (edited) Hi everyone, I have been a long time AutoIT user, but this is actually the first time I post a message in these forums. Up to now I was always able to get things to work, but this issue seems to be a bit more complex. I have two webpages for which the second one is called from the first one. The first web page contains two fields, a text field and a drop down box. The robot keys in the value "a" in the text field and select the value "b" in the drop down box. For simplicity these things are hard coded in this code sniplet. Once pressing the submit button, the second web page is loaded which also has a text field and a drop down box. I have added some message boxes in this second block and once executed I figured out that the $o_IE1 is actually the same object as in the first page. Once in the loop I see the fields from the first web page. Anyway, so it looks the $o_IE1 is not a new object. I tried to force things, by using WinActivate and _IEAttach, but this does not fully make everything work. Without those two I cannot see the form from the second page at all. Can somebody give me some directions please ? Warm regards expandcollapse popup; Add include file in program... #include "IE.au3" _IEErrorHandlerRegister() ; Initialize IE browser object... $o_IE = _IECreate("about:blank", 0, 1, 1, 1) $hGUI = WinGetHandle("[Class:IEFrame]") ; Initialize variables... $URLData = "<Internal URL>" ; Load URL in browser... _IENavigate ($o_IE, $URLData, "NoWait") ;;;; ; Page 1 ;;;; ; Get Browser form details... $oForm = _IEFormGetCollection($o_IE, 0) $oFormFields = _IEFormElementGetCollection($oForm) ; Find field name in HTML form... For $oFormField in $oFormFields If $oFormField.type = "text" Then _IEFormElementSetValue($oFormField, "a") ElseIf $oFormField.type = "select-one" Then _IEFormElementOptionSelect($oFormField, "b", 1 , "byText", 1) EndIf Next _IEFormSubmit($oForm, 0) ;<< until here everything works normal ;;;; ; Page 2 ;;;; WinActivate($hGUI) $o_IE1 = _IEAttach($hGUI, "hwnd") ; Get Browser form details... ;$oForm1 = _IEFormGetCollection($o_IE1, 0) ;$oFormFields1 = _IEFormElementGetCollection($oForm1) ; Find field name in HTML form... For $oFormField in _IEFormElementGetCollection($oForm) If $oFormField.type = "text" Then _IEFormElementSetValue($oFormField, "c") ElseIf $oFormField.type = "select-one" Then _IEFormElementOptionSelect($oFormField, "d", 1 , "byText", 1) EndIf Next _IEFormSubmit($oForm, 0) Edited February 14, 2016 by MeAgain Link to comment Share on other sites More sharing options...
Danp2 Posted February 11, 2016 Share Posted February 11, 2016 _IENavigate ($o_IE, $URLData, "NoWait") "NoWait" is not a valid parameter. This should be either a 0 or a 1. Beyond that, it's difficult to know where the issue resides with the limited details provided. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MeAgain Posted February 11, 2016 Author Share Posted February 11, 2016 It's me again, Thanks for that, I have removed the NoWait, since it is an optional parameter I believe. Not sure why you say I have provided limited details, though. I was hoping this is a 'known' issue in the community, although I could not find a lot about it in the forums. By the way my desktop is a Windows 7 machine and it is IE11. This script used to work on a Windows XP machine before, but this was about a year ago. Link to comment Share on other sites More sharing options...
JohnOne Posted February 12, 2016 Share Posted February 12, 2016 The limited details is because of the super secret url. One of the most time consuming things to solve your problem from the perspective of others, is finding an accessible website where the same problem occurs. That task should be up to you, since you are the one needing help. it is impossible to know how your confidential URL works, so it is in your best interest to provide people who might possibly solve your issue, with a means of testing it via a reproducer they can actually try. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Danp2 Posted February 12, 2016 Share Posted February 12, 2016 What AutoIt version? 3 hours ago, MeAgain said: Not sure why you say I have provided limited details, though. You haven't provided enough information to allow someone to duplicate the issue. It appears that you are accessing an internal site, so I understand that we can't test on the actual site. Have you tried to identify another publicly accessible site that could be used to demonstrate the issue? Also, you haven't shown us any of the underlying HTML code. My crystal ball is in the shop, so I'm unable to predict what is actually occurring with your unique situation. ;-) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MeAgain Posted February 12, 2016 Author Share Posted February 12, 2016 Ok, I understand, sorry for that. Please find attached all the files required to test this issue. I have now also tried it on my desktop at home, which is also a Windows 7 with IE11 machine, and there I have the same issue. Thanks in advance for helping me. Test robot.au3 test1.html test2.html test3.html Link to comment Share on other sites More sharing options...
MeAgain Posted February 12, 2016 Author Share Posted February 12, 2016 Some more info, I have just installed AutoIT on my desktop at home, so that will be version 3.3.14.0. Link to comment Share on other sites More sharing options...
Danp2 Posted February 12, 2016 Share Posted February 12, 2016 Here's a revised script that works for me: #include "IE.au3" $o_IE = _IECreate(@ScriptDir & '\test1.html') ;;;; ; Page 1 ;;;; $oForm = _IEFormGetCollection($o_IE, 0) $oField = _IEFormElementGetObjByName($oForm, "FieldA") _IEFormElementSetValue($oField, "A") $oSelect = _IEFormElementGetObjByName($oForm, "FieldB") _IEFormElementOptionSelect($oSelect, "b", 1 , "byText", 1) Sleep(2000) _IEFormSubmit($oForm) ;;;; ; Page 2 ;;;; $oForm = _IEFormGetCollection($o_IE, 0) $oField = _IEFormElementGetObjByName($oForm, "FieldC") _IEFormElementSetValue($oField, "C") $oSelect = _IEFormElementGetObjByName($oForm, "FieldD") _IEFormElementOptionSelect($oSelect, "d", 1 , "byText", 1) Sleep(2000) _IEFormSubmit($oForm) The Sleep statements are only there to allow the user to see that the fields were correctly updated. ;-) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MeAgain Posted February 12, 2016 Author Share Posted February 12, 2016 Thanks a lot Danp2 for your script. With your script I have the exact same symptons as with my original script. It does not find the fields on the second page and thus they are not populated. Which OS do you have and which version of IE ? Link to comment Share on other sites More sharing options...
Danp2 Posted February 12, 2016 Share Posted February 12, 2016 Windows 10 x64 IE 11 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mLipok Posted February 12, 2016 Share Posted February 12, 2016 13 hours ago, MeAgain said: Thanks in advance for helping me. Test robot.au3 test1.html test2.html test3.html I change this: ; Initialize variables... $URLData = @ScriptDir & "\test1.html" you should to use: #include <IE.au3> ; instead ; #include "IE.au3" unless you have your own modified version of this UDF. Question: What happend to IE when you submit open new separate IE window open new Tab in current IE window open new document in current Tab of current IE ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
MeAgain Posted February 14, 2016 Author Share Posted February 14, 2016 Ok, thanks for pointing that out. I fixed the include statement in the script, but still suffering the issue. When the robot clicks submit, it loads test2.html in the same tab, in the same IE window. Link to comment Share on other sites More sharing options...
mLipok Posted February 14, 2016 Share Posted February 14, 2016 1 hour ago, MeAgain said: When the robot clicks submit, it loads test2.html in the same tab, in the same IE window. On 11.02.2016 at 7:38 PM, MeAgain said: I have added some message boxes in this second block and once executed I figured out that the $o_IE1 is actually the same object as in the first page. Once in the loop I see the fields from the first web page. Anyway, so it looks the $o_IE1 is not a new object. This is correct, behavior in this case, as you have still the same Instance of IE object. So with this knowledge, what you want to achieve now ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
MeAgain Posted February 15, 2016 Author Share Posted February 15, 2016 I want the robot to be able fill in the fields on the second page. How do I refresh the $o_IE object, so it contains the fields in the second form ? Link to comment Share on other sites More sharing options...
MeAgain Posted February 15, 2016 Author Share Posted February 15, 2016 (edited) Me again. I just double checked this script below on a Windows XP IE8, where it works as expected. It does not work on Windows 7 IE11, on two machines. #include <IE.au3> ; Initialize IE browser object... $o_IE = _IECreate("about:blank", 0, 1, 1, 1) ; Initialize variables... $URLData = "http://192.168.1.2/test1.html" ; Load URL in browser... _IENavigate($o_IE, $URLData) ;;;; ; Page 1 ;;;; $oForm = _IEFormGetCollection($o_IE, 0) $oField = _IEFormElementGetObjByName($oForm, "FieldA") _IEFormElementSetValue($oField, "A") $oSelect = _IEFormElementGetObjByName($oForm, "FieldB") _IEFormElementOptionSelect($oSelect, "b", 1 , "byText", 1) _IEFormSubmit($oForm) ;;;; ; Page 2 ;;;; $oForm = _IEFormGetCollection($o_IE, 0) $oField = _IEFormElementGetObjByName($oForm, "FieldC") _IEFormElementSetValue($oField, "C") $oSelect = _IEFormElementGetObjByName($oForm, "FieldD") _IEFormElementOptionSelect($oSelect, "d", 1 , "byText", 1) _IEFormSubmit($oForm) Edited February 15, 2016 by MeAgain Link to comment Share on other sites More sharing options...
MeAgain Posted February 16, 2016 Author Share Posted February 16, 2016 (edited) Nobody can come with a solution, so it is moved to the General Help and Support section, right ? This simple code is not working on Windows 7 IE11 and I tried it on two different PCs ! Are you kidding me ? Edited February 16, 2016 by MeAgain Link to comment Share on other sites More sharing options...
Danp2 Posted February 16, 2016 Share Posted February 16, 2016 There was an update from MS around 18 months ago that caused havoc with IE automation. Perhaps that affecting your script. <shrug> Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mLipok Posted February 16, 2016 Share Posted February 16, 2016 (edited) 17 minutes ago, Danp2 said: There was an update from MS around 18 months ago that caused havoc with IE automation. Perhaps that affecting your script. <shrug> Was not it already been fixed ? Unless we are talking about the same problem. @MeAgain 1. Open second page. Attach to them. and check @extended Local $oFrames = _IEFrameGetCollection($oIE) MsgBox(0, 'Frame count', @extended) 2. What your script doing beetwen this two functions: _IEFormSubmit($oForm) ;;;; ; Page 2 ;;;; $oForm = _IEFormGetCollection($o_IE, 0) Edited February 16, 2016 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 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