DCAlliances Posted July 6, 2010 Share Posted July 6, 2010 (edited) Hi there I have 4 drop down list in my web app (report type, survey, client name and username) and I am using IE at this stage. The last dropdownlist (username) is depending on those dropdownlist report type, survey and client name. Basically each dropdownlist has onchange trigger. Once selected, it will refresh the page automatically and run some report on the bottom. I have managed to display to automate by pointing to the right "selection" but the last dropdownlist doesn't go to the right "selection". I tried byValue, byText and byIndex and it always to set 1 first selection. expandcollapse popupAutoItSetOption("TrayIconDebug",1) ;ProgressSet ( 25 , "25 percent" , "Get form information") ; Create a browser window and navigate to hotmail $oIE = _IECreate ("http://localhost/tvi/") $o_form = _IEFormGetObjByName ($oIE, "form1") ;The form id changed $o_login = _IEFormElementGetObjByName ($o_form, "tbUsername") $o_password = _IEFormElementGetObjByName ($o_form, "tbPassword") $o_signin = _IEFormElementGetObjByName ($o_form, "btnLogin") ;the button name changed $username = "***" $password = "XXX" _IEFormElementSetValue ($o_login, $username) _IEFormElementSetValue ($o_password, $password) _IEAction ($o_signin, "click") _IENavigate ($oIE, "http://localhost/tvi/Admin/SurveyReportByIndividual.aspx") $oForm = _IEFormGetCollection($oIE, 0) $o_ReportType = _IEFormElementGetObjByName ($oForm, "ctl00_ContentPlaceHolder1_ddlReportType") $o_Survey = _IEFormElementGetObjByName ($oForm, "ctl00_ContentPlaceHolder1_ddlSurveyID") $o_Client = _IEFormElementGetObjByName ($oForm, "ctl00_ContentPlaceHolder1_ddlClientName") $o_User = _IEFormElementGetObjByName ($oForm, "ctl00_ContentPlaceHolder1_ddlUserID") _IEFormElementOptionselect ($o_ReportType, "SummaryResultNoAnswer", 1, "byValue", 0) ;Sleep(250) _IEFormElementOptionselect ($o_Survey, 33, 1, "byValue", 0) ;Sleep(250) _IEFormElementOptionselect ($o_Client, 28, 1, "byValue", 1) ;_IELoadWait($oIE, 3000) ;Sleep(250) _IEFormElementOptionselect ($o_User, "brooke.xxx@fc.com", 1, "byText", 1) Any ideas? BTW ... I am newbie and how to debug this? How do utilise @error message? Do I need to wait in regards to this? Also, I've tried using Sleep or _IELoadWait but it seems introducing more error? Thanks Edited July 6, 2010 by DCAlliances Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 6, 2010 Share Posted July 6, 2010 (edited) Wait to retrieve the $o_User object reference until just before you need to use it. When the page gets refreshed/navigated, the old reference may not be valid anymore. P.S. Refresh/Navigation may also invalidate $oForm, but $oIE will still be valid. Edited July 6, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DCAlliances Posted July 6, 2010 Author Share Posted July 6, 2010 (edited) Wait to retrieve the $o_User object reference until just before you need to use it. When the page gets refreshed/navigated, the old reference may not be valid anymore. P.S. Refresh/Navigation may also invalidate $oForm, but $oIE will still be valid.How to wait $o_User though? Also in regards to this: "Refresh/Navigation may also invalidate $oForm, but $oIE will still be valid. " I am not sure what I need to with this. Edited July 6, 2010 by DCAlliances Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 6, 2010 Share Posted July 6, 2010 When you set the options for $o_ReportType, $o_Survey, and $o_Client, what does the browser do (before you try to use $o_User)? If setting those first three options causes the page to reload (like via an "onchange" event), then you might have to reacquire $oForm and $o_User from the newly refreshed page before trying to work with them. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DCAlliances Posted July 6, 2010 Author Share Posted July 6, 2010 When you set the options for $o_ReportType, $o_Survey, and $o_Client, what does the browser do (before you try to use $o_User)?If setting those first three options causes the page to reload (like via an "onchange" event), then you might have to reacquire $oForm and $o_User from the newly refreshed page before trying to work with them.Hi PsaltyDS. I've managed to make it work actually. You guys right. Due to firing up onchange, the reference of the object is clear so that's why I reset again for form as well as putting the relevant object sequence after onchange happening.Thanks for this. 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