Jump to content

_IEGetObjById can't read a value from div id


stojko22
 Share

Recommended Posts

Hi,

I'm trying to make a program to connect on my modem over web, since this is my only option to access my modem.

I want to edit my wi-fi network and manage ip-s connected to it.

But i get to a problem where i can't read a id from html when i login to my modem interface.

Problem is appear when i try to read id and click on the item to open menu with sub items to i can get to my wi-fi configuration.

Here is a code and image

#include <IE.au3>

Global $URL = '192.168.1.1'

$ie = _IECreate ($URL, 0, 1, 1, 0) ; url, try attach, visible, wait, take focus
$user = _IEGetObjById($ie, 'Frm_Username')  ; get user field
_IEFormElementSetValue ($user, 'user')      ; set username
$pass = _IEGetObjById($ie, 'Frm_Password')  ; get password field
_IEFormElementSetValue($pass, 'user')       ; set password
$submit = _IEGetObjById($ie, 'LoginId')     ; get id of submit button
_IEAction($submit, 'click')                 ; click to submit / login
Sleep(5000)

; here i got error
;~ --> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (mmNet)
;~ --> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType

$networkTab = _IEGetObjById($ie, 'mmNet')   ; get id of network div
_IEAction($networkTab, 'click')             ; click on Network tab


; this i try to read
;~ <td class="mid" id="mmNet">Network</td>

 

aa.png

Link to comment
Share on other sites

Several possibilities comes to mind --

1. The page hasn't fully loaded. You could try adding an _IELoadWait after the initial _IEAction (where you current have the Sleep command)

2. Perhaps to page uses frames. Look at the example code in the help file under the entry for _IEFrameGetCollection. You could try running this to check for frames.

Link to comment
Share on other sites

I added a _IELoadWait and try to run code but same problem. I put _IECreate to make a visible window so i can see what it does.

It successfully open address, login to panel and opens me a panel, but won't click a "Network tab".

Then i used a _IEFrameGetCollection to get data after successfully login and i got this :

Spoiler

Frames Info - 2 frames found

ZXV10 H201L
 

 Error


 
 


 Help  
Display primary information of this device: carrier, model name, serial number, batch number, hardware version, software version, boot loader version, DSL firmware version, etc. 
 
 
 


 Status
 Device Information 
 Network Interface
 User Interface
 VoIP Status
 Network
 Application
 Administration
 Help


Help


   
 

 


Path:Status-Device Information 

Logout 
 


Carrier
ModelZXV10 H201L
Serial NumberZTEEF01DB701969 
batch number07ddT030145
Hardware VersionV1.0.05
Software VersionV1.0.01_H1BT03
Boot Loader VersionV1.0.11
DSL Firmware Version4.4.6.3.0.2

 


  
Copyright © 2011 ZTE Corporation. All rights reserved.


  var x,y,z,obj;var down=false;var browser=navigator.appName;var b_version=navigator.appVersion;var version=b_version.split(";");var trim_Version = "";if(null != version[1]){trim_Version=version[1].replace(/[ ]/g,"");}function setinner(type){if(browser=="Microsoft Internet Explorer"&& trim_Version=="MSIE6.0"){document.getElementById("myLayer").style.visibility = type;}else {document.getElementById("myLayer").style.visibility = type ;}}function setinnerHidden(){if(browser=="Microsoft Internet Explorer"&& trim_Version=="MSIE6.0"){document.getElementById("myLayer").style.visibility = "hidden";}else {document.getElementById("myLayer").style.visibility = "hidden";}}function init(){if(browser=="Microsoft Internet Explorer"&& trim_Version=="MSIE6.0"){obj=event.srcElement;obj.setCapture();z=obj.style.zIndex;obj.style.zIndex=100 ;x=event.offsetX;y=event.offsetY ;down=true;}}function moveit(){if(browser=="Microsoft Internet Explorer"&& trim_Version=="MSIE6.0"){if(down&&event.srcElement==obj){with(obj.style){posLeft=document.body.scrollLeft+event.x-x;posTop=document.body.scrollTop+event.y-y;}}}}function stopdrag(){if(browser=="Microsoft Internet Explorer"&& trim_Version=="MSIE6.0"){down=false;obj.style.zIndex=z ;obj.releaseCapture();}}function framedispalay(id){if(browser=="Microsoft Internet Explorer"&& trim_Version=="MSIE6.0"){}else {getObj(id).style.display="none";}}this.remove=function(){getObj("alertFram").style.display = "none";};var ie=document.all;var nn6=document.getElementById&&!document.all;var isdrag=false;var y,x;var oDragObj;function moveMouse(e){if (isdrag){oDragObj.style.top = (nn6 ? nTY + e.clientY - y : nTY + event.clientY - y)+"px";oDragObj.style.left = (nn6 ? nTX + e.clientX - x : nTX + event.clientX - x)+"px";return false;}}function initDrag2(o,s){if (typeof(o) == "string") o = document.getElementById(o);o.orig_x = parseInt(o.style.left) - document.body.scrollLeft;o.orig_y = parseInt(o.style.top) - document.body.scrollTop;o.orig_index = o.style.zIndex;o.onmousedown = function(evt){this.style.cursor = "move";var d=document;evt = evt || window.event;var x = evt.clientX+d.body.scrollLeft-o.offsetLeft;var y = evt.clientY+d.body.scrollTop-o.offsetTop;d.ondragstart = "return false;";d.onselectstart = "return false;";d.onselect = "document.selection.empty();";if(o.setCapture)o.setCapture();else if(window.captureEvents)window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);d.onmousemove = function(evt){evt = evt || window.event;o.style.left = evt.clientX+document.body.scrollLeft-x +"px";o.style.top = evt.clientY+document.body.scrollTop-y +"px";o.orig_x = parseInt(o.style.left) - document.body.scrollLeft;o.orig_y = parseInt(o.style.top) - document.body.scrollTop;};d.onmouseup = function(){if(o.releaseCapture)o.releaseCapture();else if(window.captureEvents)window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);d.onmousemove = null;d.onmouseup = null;d.ondragstart = null;d.onselectstart = null;d.onselect = null;o.style.cursor = "normal";o.style.zIndex = o.orig_index;};};if (s){var orig_scroll = window.onscroll?window.onscroll:function (){};window.onscroll = function (){orig_scroll();o.style.left = o.orig_x + document.body.scrollLeft;o.style.top = o.orig_y + document.body.scrollTop;};}}function initDrag(e){var oDragHandle = nn6 ? e.target : event.srcElement;var topElement = "HTML";if( oDragHandle.tagName ){while (oDragHandle.tagName != topElement && oDragHandle.className != "dragAble"){oDragHandle = nn6 ? oDragHandle.parentNode : oDragHandle.parentElement;}if (oDragHandle.className=="dragAble"){isdrag = true;oDragObj = oDragHandle;nTY = parseInt(oDragObj.style.top+0);y = nn6 ? e.clientY : event.clientY;nTX = parseInt(oDragObj.style.left+0);x = nn6 ? e.clientX : event.clientX;document.onmousemove=moveMouse;return false;}}}function showHelp(){getObj("alertFram").style.display = "block";var helpiframe = document.getElementById('helpiframe');helpiframe.setAttribute('height', document.getElementById('dragAble').scrollHeight);framedispalay("helpiframe");initDrag2('dragAble');}function jump(){top.location.href = "/";}function AutoRelogin(type){var timeout;if ((type == "restart") || (type == "upgconfig")){timeout = 3;}else if (type == "restore"){timeout = 3;}else if (type == "upgversion"){timeout = 5;}else {return;}setTimeout("jump()", timeout*60*1000+5000);}function OldProcessRet(errstr, errpara){if("Current operation is ineffective, please check whether "== errstr && "SUCC"== errpara){errstr = "FAIL";}ProcessRet(errstr, errpara);}function ProcessRet(errstr, errpara){var errtype=getValue("IF_ERRORTYPE");if (errstr != "SUCC"){if(errpara != "SUCC"){var param = document.getElementById("Fnt_"+errpara);if ( param== null){ShowErrorForCom(null, null, "Current operation is ineffective, please check configuration parameters.");}else {msg = "Current operation is ineffective, please check whether "+ param.innerHTML + " is legal.";ShowErrorForCom("Frm_"+errpara, null, msg);}}else {if (errstr == "FAIL"){errstr = "Current operation is ineffective, please check configuration parameters.";}if ((errtype&1) == 1){ShowNote("Notice", errstr);}else if((errtype&2) == 2){ShowErrorForCom(null, null, errstr);}else if((errtype&4) == 4){}else {ShowErrorForCom(null, null, errstr);}}}} getObj("IF_UPLOADING").value = "N/A"; text = "<table class='bottom_table' border='0' cellpadding='0' cellspacing='0'>" +"<tbody><tr>" +"<td class='bottom_td1'></td>" +"<td class='bottom_td2' style='background:url(img/bottom_left.gif) no-repeat left top;'></td>" +"<td class='bottom_td3'>" +"</td></tr></tbody>" +"</table>"; getObj("bottom").innerHTML=text; meta_menu = new Array(); menu_items = new Array(); menu_subitems = new Array(); meta_menu['mmStatu'] = new Array(); meta_menu['mmStatu']['langName'] = 'Status'; meta_menu['mmStatu']['page'] = 'status_dev_info_t.gch'; menu_items['mmStatu'] = new Array(); menu_subitems['mmStatu'] = new Array(); menu_items['mmStatu']['smDevStatu'] = new Array(); menu_items['mmStatu']['smDevStatu']['langName'] = 'Device Information '; menu_items['mmStatu']['smDevStatu']['page'] = 'status_dev_info_t.gch'; menu_items['mmStatu']['smWanStatu'] = new Array(); menu_items['mmStatu']['smWanStatu']['langName'] = 'Network Interface'; menu_items['mmStatu']['smWanStatu']['page'] = 'IPv46_status_wan_if_t.gch'; menu_subitems['mmStatu']['smWanStatu'] = new Array(); menu_items['mmStatu']['smLanStatu'] = new Array(); menu_items['mmStatu']['smLanStatu']['langName'] = 'User Interface'; menu_items['mmStatu']['smLanStatu']['page'] = 'status_wlan_info_t.gch'; menu_subitems['mmStatu']['smLanStatu'] = new Array(); menu_items['mmStatu']['smVOIPStatu'] = new Array(); menu_items['mmStatu']['smVOIPStatu']['langName'] = 'VoIP Status'; menu_items['mmStatu']['smVOIPStatu']['page'] = 'status_voip_4less_t.gch'; meta_menu['mmNet'] = new Array(); meta_menu['mmNet']['langName'] = 'Network'; meta_menu['mmNet']['page'] = 'net_11n_conf_t.gch'; meta_menu['mmApp'] = new Array(); meta_menu['mmApp']['langName'] = 'Application'; meta_menu['mmApp']['page'] = 'app_ddns_conf_t.gch'; meta_menu['mmManager'] = new Array(); meta_menu['mmManager']['langName'] = 'Administration'; meta_menu['mmManager']['page'] = 'manager_user_conf_t.gch'; meta_menu['mmHelp'] = new Array(); meta_menu['mmHelp']['langName'] = 'Help'; meta_menu['mmHelp']['page'] = 'help_t.gch'; var selectPage = "status_dev_info_t.gch"; var selectSupId = "mmStatu"; function menuUpdate() { text = "<table class='menu' border='0' cellpadding='0' cellspacing='0'>" + "<tbody>" + "<tr>" + "<td class='h1_mid'><a name='top'></a>" + "<table class='menu_table' border='0' cellpadding='0' cellspacing='0'>" + "<tbody>"; for (var supId in meta_menu) { text = text + "<tr class='"; var temp = "' style='cursor:pointer' onclick=\"javascript:openLink('" + meta_menu[supId]['URL'] + "')\" onmouseover=\"altMenuClass(this,true)\" onmouseout=\"altMenuClass(this,false)\">" + "<td class='add'>&nbsp;</td>" + "<td class='mid' id='"+supId+"'>" + meta_menu[supId]['langName'] + "</td>" + "</tr>"; if( supId != selectSupId ) { text = text + "h1" + temp; continue; } else { text = text + "h1_s" + temp; } for ( var midId in menu_items[supId] ) { var stat = getMidMenuStat(supId, midId); if ( stat == "single" ) { if (menu_items[supId][midId]['page'] == selectPage) { text = text + "<tr class='h2_s' onmouseover=\"altMenuClass(this,true)\" onmouseout=\"altMenuClass(this,false)\">" + "<td class='add'>&nbsp;</td>" + "<td class='mid'>" + "<font id='"+midId+"'>" + menu_items[supId][midId]['langName'] + "</font></td>" + "</tr>"; getObj("title_path").innerHTML="Path:"+meta_menu[supId]['langName']+"-"+menu_items[supId][midId]['langName']; } else { text = text + "<tr class='h2_content' style='cursor:pointer' onclick='javascript:openLink(\"" + menu_items[supId][midId]['URL'] + "\")' onmouseover=\"altMenuClass(this,true)\" onmouseout=\"altMenuClass(this,false)\">" + "<td class='add'>&nbsp;</td>" + "<td class='mid'>" + "<font id='"+midId+"'>" + menu_items[supId][midId]['langName'] + "</font></td>" + "</tr>"; } } else if ( stat == "closed" ) { text = text + "<tr class='h2_content' style='cursor:pointer' onclick='javascript:OnMenuItemClick(\"" + supId + "\",\"" + midId + "\"); openLink(\"" + menu_items[supId][midId]['URL'] + "\")' onmouseover=\"altMenuClass(this,true)\" onmouseout=\"altMenuClass(this,false)\">" + "<td class='add'>&nbsp;</td>" + "<td class='mid'>" + "<span style='color:green; font-size:12.0pt; font-family:Arial'></span> " + "<font id='"+midId+"'>" + menu_items[supId][midId]['langName'] + "</font></td>" + "</tr>"; } else if ( stat == "open" ) { text = text + "<tr class='h2_s' onmouseover=\"altMenuClass(this,true)\" onmouseout=\"altMenuClass(this,false)\">" + "<td class='add'>&nbsp;</td>" + "<td class='mid'>" + "<span style='font-size:12.0pt; font-family:Arial'></span>" + "<font id='"+midId+"'>" + menu_items[supId][midId]['langName'] + "</font></td>" + "</tr>"; for (var subId in menu_subitems[supId][midId]) { if (menu_subitems[supId][midId][subId]['page'] == selectPage) { text = text + "<tr class='h3_s' onmouseover=\"altMenuClass(this,true)\" onmouseout=\"altMenuClass(this,false)\">" + "<td class='add'>&nbsp;</td>" + "<td class='mid'>" + "<font id='"+subId+"'>" + menu_subitems[supId][midId][subId]['langName'] + "</font></td>" + "</tr>"; getObj("title_path").innerHTML="Path:"+meta_menu[supId]['langName']+"-"+menu_items[supId][midId]['langName']+"-"+menu_subitems[supId][midId][subId]['langName']; } else { text = text + "<tr class='h3' style='cursor:pointer' onclick=\"javascript:openLink('" + menu_subitems[supId][midId][subId]['URL'] + "' )\" onmouseover=\"altMenuClass(this,true)\" onmouseout=\"altMenuClass(this,false)\">" + "<td class='add'>&nbsp;</td>" + "<td class='mid' colspan='2'>" + "<font id='"+subId+"'>" + menu_subitems[supId][midId][subId]['langName'] + "</font></td>" + "</tr>"; } } } } } text = text + "<tr class='h2_space'>" + "<td colspan='3'></td>" + "</tr>" + "<tr class='h2_help'>" + "<td class='add'></td>" + "<td class='mid_right'>" + "<div>" + "<ul>" + "<li class='help'>" + "<span style=\"cursor:pointer\" onclick=\"showHelp();\"><img id=\"sss\" src=\"img/help.gif\" border='0'><b style=\"color:rgb(62,62,62);padding-bottom:5px;padding-right:5px;\">"+"Help"+"</b></span>" + "</li>" + "</ul>" + "</div>" + "</td>" + "</tr>"; text = text + "</tbody>" + "</table>" + "</td>" + "</tr>" + "</tbody>" + "</table>"; getObj("menu0").innerHTML=text; } function altMenuClass(ele) { var map = {"h1":"h1 bghover","h1 bghover":"h1","h1_s":"h1_s bghover h1_s_bgfix","h1_s bghover h1_s_bgfix":"h1_s","h2":"h2 bghover","h2 bghover":"h2","h2_s":"h2_s bghover","h2_s bghover":"h2_s","h2_content":"h2_content bghover","h2_content bghover":"h2_content","h3":"h3 bghover","h3 bghover":"h3","h3_s":"h3_s bghover","h3_s bghover":"h3_s"}; ele.className = map[ele.className] || ele.className; } function myOnLoad() { menuDisp(); addEvent(getObj("htmlBody"), "keydown", setenter); addEvent(getObj("htmlBody"), "keyup", setinnerHidden); addEvent(getObj("htmlBody"), "mousedown", setinnerHidden); fnBreakWordAll({word:15,re:'[\\w]'}); framedispalay('myiframe'); } myOnLoad();  
 

Code

#include <IE.au3>

Global $URL = '192.168.1.1'

$ie = _IECreate ($URL, 0, 1, 1, 0) ; url, try attach, visible, wait, take focus
$user = _IEGetObjById($ie, 'Frm_Username')  ; get user field
_IEFormElementSetValue ($user, 'user')      ; set username
$pass = _IEGetObjById($ie, 'Frm_Password')  ; get password field
_IEFormElementSetValue($pass, 'user')       ; set password
$submit = _IEGetObjById($ie, 'LoginId')     ; get id of submit button
_IEAction($submit, 'click')                 ; click to submit / login

_IELoadWait($ie, 5000) ; after login to modem panel

Local $oFrames = _IEFrameGetCollection($ie)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFrame = 0
For $i = 0 To ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection($ie, $i)
    $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
Next
ConsoleWrite("Frames Info - " & $sTxt & @CRLF)

And this is an image of a panel

 

bb.png

Edited by stojko22
Link to comment
Share on other sites

So you've identified that there are frames invoived. That's good. Now you need to figure out which frame contains the desired element. Then you would add something like this --

oFrame = _IEFrameGetCollection($ie, 0)          ; assumes the first frame is the desired one
$networkTab = _IEGetObjById($oFrame, 'mmNet')   ; get id of network div
_IEAction($networkTab, 'click')                 ; click on Network tab

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...