HuaAi Posted August 8, 2015 Share Posted August 8, 2015 Hi all,I can't seem to get a search box by its id using _IEFrameGetObjById(). I am suspecting that it's because this object is in an iframe. Is there a way to get the object in an iframe using IE.au3 library? Your help is very much appreciated! Below are the source code extracted from the page:<div id="horde-search"> <form action="" method="get"> <div class="horde-fake-input"> <span id="horde-search-dropdown"> <span class="iconImg horde-popdown"></span> </span> <input title="Search (Entire Message)" class="formGhost" id="horde-search-input" type="text" autocomplete="off"> </div> <input id="horde-search-icon" type="image" src="/cpsess6708041454/horde/themes/default/graphics/search-topbar.png"> </form> </div>Below are my AutoIt script:#include <IE.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> Global $oIE ; object variable pointing to an IE.Application object Global $hIE ; handle to IE window Global $oObj ; object variable pointing to an IE.Application, window, or frame object Global $delayFactor = 100 $oIE = _IEAttach("Webmail - Main", "title") Sleep($delayFactor) $hIE = _IEPropertyGet($oIE, "hwnd") Sleep($delayFactor) $oObj = _IEGetObjById($oIE,"horde-search-input") If @error = 0 Then BreakPoint("Found it!!") Else BreakPoint("Can't find it!!") EndIf BreakPoint("End of debug") ExitI also copied the complete source code of the page below in case it's needed for debugging:expandcollapse popup<html lang="en" dir="ltr"><head> <title>Webmail - Main</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="/brand/favicon.ico?36401886" rel="shortcut icon" type="image/x-icon"> <link href="/cPanel_magic_revision_1438741740/webmail/gl_paper_lantern/_assets/css/master-ltr.cmb.min.css" rel="stylesheet" type="text/css"> <link href="/cPanel_magic_revision_1428562401/webmail/gl_paper_lantern/mail_clients/mail_clients.css" rel="stylesheet" type="text/css"> <script src="/cPanel_magic_revision_1438741299/webmail/gl_paper_lantern/_assets/js/master-legacy.cmb.min.js" type="text/javascript"></script> <script src="/cPanel_magic_revision_1438748026/cjt/cpanel-all-en.js" type="text/javascript"></script> <script src="/cPanel_magic_revision_1438741178/cjt/cpanel-all-min.js" type="text/javascript"></script> <script type="text/javascript"> CPANEL.validate.hide_validation_summary = true; </script> <script> (function(){ window.PAGE = {}; window.NVData = {}; window.NVData["webmailclient"] = "sqmail"; window.NVData["hideUserPreferencesOverlay"] = "1"; window.thisTheme = "gl_paper_lantern"; })(); </script> <!-- custom style css file (styles.css) should go here --> <link href="/styled/current_style/sprites/icon_spritemap.css?36401886" rel="stylesheet" type="text/css"> <link href="/styled/current_style/styles.css?36401886" rel="stylesheet" type="text/css"> </head> <body class="yui-skin-sam" id="cpanel_body"> <div id="wrap"> <header> <div class="navbar navbar-inverse navbar-cpanel navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" id="lnkHeaderHome" href="index.html" target="_top"> <img class="navbar-brand-logo" id="imgLogo" alt="cPanel" src="/brand/logo.png?36401886"> </a> <div class="navbar-preferences"> <span class="navbar-overlay-wrapper" id="userPreferencesContainer"> <div class="btn-group"> <button class="btn btn-primary dropdown-toggle" id="btnUserPref" data-toggle="dropdown"> <span class="glyphicon glyphicon-user" id="userImg"></span> <span class="hidden-inline-xs" id="lblUserNameTxt">requester1@lyntact.com</span> <span class="caret" id="caretImg"></span> </button> <ul class="dropdown-menu dropdown-menu-right"> <li class="mail-app"> <a class="mail-app-name" id="lnkUserPrefhorde" href="index.html?mailclient=horde"> Horde </a> <a title="Set as my default webmail application" class="mail-app-fav" id="lnkUserPrefhordeFav" href="javascript:void(0);" data-webmail-client="horde"> <span class="fa fa-fw pull-right fa-star" id="imgUserPrefhorde" data-webmail-client="horde" alt="Set as my default webmail application"></span> </a> </li> <li class="mail-app"> <a class="mail-app-name" id="lnkUserPrefroundcube" href="index.html?mailclient=roundcube"> Roundcube </a> <a title="Set as my default webmail application" class="mail-app-fav" id="lnkUserPrefroundcubeFav" href="javascript:void(0);" data-webmail-client="roundcube"> <span class="fa fa-fw pull-right fa-star-o" id="imgUserPrefroundcube" data-webmail-client="roundcube" alt="Set as my default webmail application"></span> </a> </li> <li class="mail-app"> <a class="mail-app-name" id="lnkUserPrefsqmail" href="index.html?mailclient=sqmail"> SquirrelMail </a> <a title="Set as my default webmail application" class="mail-app-fav" id="lnkUserPrefsqmailFav" href="javascript:void(0);" data-webmail-client="sqmail"> <span class="fa fa-fw pull-right fa-star-o" id="imgUserPrefsqmail" data-webmail-client="sqmail" alt="Set as my default webmail application"></span> </a> </li> <li class="divider"></li> <li> <a id="lnkUserPrefChangePwd" href="mail/change_password.html?redirectdomain=&email=requester1&domain=lyntact.com">Change Password </a> </li> <li> <a id="lnkUserPrefConfigMailClient" href="mail/clientconf.html?domain=lyntact.com&redirectdomain=&acct=requester1@lyntact.com&archiving=0"> Configure Mail Client </a> </li> <li> <a id="lnkUserPrefConfigCalendarContactClient" href="mail/calendars_and_contacts/index.html.tt"> Configure Calendar and Contacts Client </a> </li> <li class="divider"></li> <li> <a id="lnkUserPrefEmailFiltering" href="mail/filters/userfilters.html"> </a> </li> <li> <a id="lnkUserPrefForwarder" href="mail/fwds.html">Forwarders </a> </li> <li> <a id="lnkUserPrefAutoResponders" href="mail/autores.html">Autoresponders </a> </li> <li> <a id="lnkUserPrefUpdateContactInfo" href="contact/index.html">Contact Information </a> </li> <li> <a id="lnkUserPrefEmailTrace" href="mail/route.html">Track Delivery </a> </li> </ul> </div> <div class="navbar-overlay-message row hidden"> <div class="col-xs-10"> <h4 id="txtNavbarOverlayMessage">Change your email configuration options anytime.</h4> <button class="btn btn-default" id="btnNavbarOverlayConfirm" type="button">Got it</button> </div> <div class="col-xs-2"> <span class="fa fa-reply fa-3x fa-rotate-90" id="icnNavbarOverlayIndicator"></span> </div> </div> </span> <a class="btn btn-default" id="lnkHeaderLogout" href="/logout/?locale=en" target="_top"> <span class="glyphicon glyphicon-log-out" id="logoutImg"></span> <span class="hidden-inline-xs" id="lblLogout">Logout</span> </a> </div> </div> </div> </div> </header> <!-- PAGE TEMPLATE'S CONTENT START --> <div class="container" id="content"> <iframe width="100%" height="950" id="mailFrame" src="/cpsess6708041454/horde/index.php?cpanel=1" seamless="seamless"></iframe> <style> #wrap{ min-width: 1300px; background-repeat: repeat-x; } #content { width: 100%; margin: 0; padding:0; } #topline { display: none; } .minmodetoggle { display: none; } .button-logout { display: none; } </style> </div> <!-- PAGE TEMPLATE'S CONTENT END --> </div> <footer> <div class="container"> <div class="navbar"> <ul class="nav navbar-nav"> <li> <a id="lnkFooterHome" href="index.html">Home </a> </li> <li> <a id="lnkFooterTrademark" href="trademarks.html" target="_blank">Trademarks </a> </li> <li> <a id="lnkFooterDocs" href="http://go.cpanel.net/paperlanterndocs" target="_blank">Documentation </a> </li> </ul> <div class="navbar-brand" style="display: inline-block; visibility: visible; z-index: 2147483647;"> <a title="cPanel, Inc." id="lnkPoweredByCpanel" style="display: inline-block; visibility: visible; z-index: 2147483647;" href="http://www.cpanel.net" target="cpanel"> <img id="imgPoweredByCpanel" style="display: inline-block; visibility: visible; z-index: 2147483647;" alt="cPanel, Inc." src="/cPanel_magic_revision_1438741435/img-sys/powered_by_cpanel.png"> </a> <sub id="txtCpanelVersion" style="display: inline-block; visibility: visible; z-index: 2147483647;">11.50.0.23</sub> </div> </div> </div> </footer> <script> CPANEL.lang.close="Close";CPANEL.lang.Close="Close";CPANEL.lang.cancel="Cancel";CPANEL.lang.unlimited="Unlimited";CPANEL.lang.or="or";CPANEL.lang.ajax_loading="Loading?…";CPANEL.lang.password_generator="Password Generator";CPANEL.lang.generate_password="Generate Password";CPANEL.lang.advanced="Advanced Options";CPANEL.lang.confirm_copy_password="I have copied this password in a safe place.";CPANEL.lang.use_password="Use Password";CPANEL.lang.length="Length";CPANEL.lang.alpha_characters="Alpha Characters";CPANEL.lang.nonalpha_characters="Non Alpha Characters";CPANEL.lang.both="Both";CPANEL.lang.lowercase="Lowercase";CPANEL.lang.uppercase="Uppercase";CPANEL.lang.numbers="Numbers";CPANEL.lang.symbols="Symbols";CPANEL.lang.password_strength="Password Strength";CPANEL.lang.passwords_match="Passwords Match";CPANEL.lang.password_validator_strength="Password strength must be at least:";CPANEL.lang.password_validator_no_spaces="Password cannot have spaces.";CPANEL.lang.password_validator_no_empty="Password cannot be empty.";CPANEL.lang.password_validator_no_match="Passwords do not match.";CPANEL.lang.Validation_Errors="Validation Errors";CPANEL.lang.strength_phrase_very_weak="Very Weak";CPANEL.lang.strength_phrase_weak="Weak";CPANEL.lang.strength_phrase_ok="OK";CPANEL.lang.strength_phrase_strong="Strong";CPANEL.lang.strength_phrase_very_strong="Very Strong";CPANEL.lang.click_to_close="Click to close.";CPANEL.lang.toggle_more="more ?";CPANEL.lang.toggle_less="less ?";CPANEL.lang.Error="Error";CPANEL.lang.json_error="Error";CPANEL.lang.json_parse_failed="JSON parse failed.";CPANEL.lang.ajax_error="AJAX Error";CPANEL.lang.ajax_try_again="Please refresh the page and try again.";CPANEL.lang.Search="Search";CPANEL.lang.Simple_Search="Simple Search";CPANEL.lang.Advanced_Search="Advanced Search";CPANEL.lang.add_search_field="add search field";CPANEL.lang.remove="remove";CPANEL.lang.No_Results_Found="No Results Found";CPANEL.lang.Go_to="Go to";CPANEL.lang.Show_rows="Show rows";CPANEL.lang.contains="contains";CPANEL.lang.equals="equals";CPANEL.lang.More="More";CPANEL.lang.ajax_error_with_image=CPANEL.icons.error+" "+this.ajax_error+": "+this.ajax_try_again;CPANEL.lang.json_error_with_image=CPANEL.icons.error+" "+this.json_error+": "+this.ajax_try_again; </script> <script src="/cPanel_magic_revision_1438741179/webmail/gl_paper_lantern/_assets/base.js" type="text/javascript"></script> <script> $(function(){ var mail_client; mail_client = "horde" $("#mailFrame").load(function(){ if(mail_client === "roundcube"){ $("#mailFrame").contents().find(".button-logout").hide(); } if(mail_client === "horde"){ $("#mailFrame").contents().find("#horde-logout").hide(); } if(mail_client === "sqmail"){ hide_squrrel_mail_logout(); } }); function hide_squrrel_mail_logout() { var squrrel_mail_frame = $("#mailFrame").contents().find('frame[name="right"]')[0]; if(squrrel_mail_frame){ $(squrrel_mail_frame.contentDocument.getElementsByClassName("sqm_headerSignout")).hide(); $("#mailFrame").contents().find('frame[name="right"]')[0].onload = function() { $(this.contentDocument.getElementsByClassName("sqm_headerSignout")).hide() }; } } } ); </script> <script> $( function() { var img = $("#imgPoweredByCpanel"); if(img === null || img.length <= 0 || img.attr('src') !== "/cPanel_magic_revision_1438741435/img-sys/powered_by_cpanel.png") { window.location="/"; } // Warning Duplicate IDs var ids = {}; $('[id]').each(function(){ if(ids[this.id]) { console.warn('Duplicate ID #'+this.id); } ids[this.id] = 1; }); } ); </script> </body></html> Link to comment Share on other sites More sharing options...
Danp2 Posted August 8, 2015 Share Posted August 8, 2015 You need to get a reference to the frame first using _IEFrameGetObjByName. Then use this reference in place of the "normal" IE object. HuaAi 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
HuaAi Posted August 9, 2015 Author Share Posted August 9, 2015 You need to get a reference to the frame first using _IEFrameGetObjByName. Then use this reference in place of the "normal" IE object.Thank you for your reply! Do you mean something like this?$oframe = _IEFrameGetObjByName(...)$oObj = _IEGetObjById($oframe, $id) Link to comment Share on other sites More sharing options...
Danp2 Posted August 9, 2015 Share Posted August 9, 2015 Yes, that's exactly what I meant. ;-) HuaAi 1 Latest Webdriver UDF Release Webdriver Wiki FAQs 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