Not able to identify the object with xpath & given properties

Hi,
I am new to selenium & automating an app where I am facing problem of identifying object.For that object in application, the object description is shown as below

 

<Img border=”0” alt=”Logout” title=”Logout” src=”Logout.png”>

 

I am not able to identify above object. I tried xpath, for xpath I am able to identify the object in selenium IDE but when I used that path in program it is not identifying that object & not performing the operation.

 

Can anybody suggest me how to identify this object

Regards,
Abhijit

Train Asked on December 7, 2015 in Selenium WebDriver.
Add Comment
  • 2 Answer(s)

    We would need more information like
    – More of the surrounding HTML code.
    – Your test code that you have written to identify this element.

    Virender

    Professor Answered on December 7, 2015.

    Hi,

    Below is the heml code for that page

    <document>
    <html>
    <head>
    <body style=”margin:0px”>
    <meta content=”text/html; charset=ISO-8859-1″ http-equiv=”Content-Type”/>
    <script src=”js/menu.js” language=”JavaScript”/>
    <link href=”includes/style/bluish.css” type=”text/css” rel=”stylesheet”/>
    <script language=”JavaScript” type=”text/javascript”><!– function toggle(object) { var Event = window.event || arguments.callee.caller.arguments[0]; if (document.getElementById) { if (document.getElementById(object).style.visibility == ‘visible’) document.getElementById(object).style.visibility = ‘hidden’; else { document.getElementById(object).style.left = Event.x+15; document.getElementById(object).style.top = Event.y-20; document.getElementById(object).style.visibility = ‘visible’; } } else if (document.layers && document.layers[object] != null) { if (document.layers[object].visibility == ‘visible’ || document.layers[object].visibility == ‘show’ ) document.layers[object].visibility = ‘hidden’; else { document.layers[object].left = Event.x+15; document.layers[object].top = Event.y-20; document.layers[object].visibility = ‘visible’; } } else if (document.all) { if (document.all[object].style.visibility == ‘visible’) document.all[object].style.visibility = ‘hidden’; else { document.all[object].style.pixelLeft = document.body.scrollLeft + Event.x + 1; document.all[object].style.pixelTop = document.body.scrollTop + Event.y + 1; document.all[object].style.visibility = ‘visible’; } } return false; } //–></script>
    <script src=”js/donothing.js” language=”JavaScript”/>
    <script src=”js/confirmany.js” language=”JavaScript”/>
    <script src=”js/validatedate.js” language=”JavaScript”/>
    <script language=”JavaScript”> <!– // handleEnter allows forms to ‘tab’ to the next field when the enter key is pushed, instead of submitting function handleEnter (field, event) { var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; var images = new Array(); if (typeof document.getElementsByTagName != ‘undefined’) { var inputs = document.getElementsByTagName(‘input’); for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == ‘image’) { images[images.length] = inputs[i]; } } } if (keyCode == 13) { if (field.tabIndex > 0) { for (i = 0; i < field.form.elements.length; i++) { if (field.tabIndex+1 == field.form.elements[i].tabIndex) { if(field.form.elements[i].type!=’hidden’) { field.form.elements[i].focus(); return false; } } } for (i = 0; i < images.length; i++) { if (field.tabIndex+1 == images[i].tabIndex) { images[i].focus(); return false; } } } var i; for (i = 0; i < field.form.elements.length; i++) if (field == field.form.elements[i]) break; i++; for(j=0; j<field.form.elements.length; j++) { i = (i + 1) % field.form.elements.length; if(field.form.elements[i].type!=’hidden’) { break; } } field.form.elements[i].focus(); return false; } else return true; } //–> </script>
    <script language=”JavaScript”> <!– function highlightField (field,select) { field.style.backgroundColor=’#EFEFEF’; if (select&&field.type==”text”) field.select(); } function normalField (field) { field.style.backgroundColor = ‘#FFFFFF’; } function highlightFieldFirst () { var i; i = 0; if (!document.forms[0]==undefined) { //if the page has a form while (document.forms[0].elements[i].type==”hidden”) { //find the first visible field i++ } if (document.forms[0].elements[i].type==”text”) document.forms[0].elements[i].select(); document.forms[0].elements[i].focus(); if (document.forms[0].elements[i].type==”text”||document.forms[0].elements[i].type==”select”||document.forms[0].elements[i].type==”textarea”) highlightField(document.forms[0].elements[i], ‘1’); } } //–> </script>
    <script language=”JavaScript”> <!– function validatenum(field) { var valid = “0123456789.-” var temp; for (var i=0; i<field.value.length; i++) { temp = “” + field.value.substring(i, i+1); if (valid.indexOf(temp) == “-1”) { field.value=(field.value.substring(0,i)+(field.value.substring(i+1,field.value.length))); i– } } } //–> function validatenum2(field) { var valid = “0123456789” var temp; for (var i=0; i<field.value.length; i++) { temp = “” + field.value.substring(i, i+1); if (valid.indexOf(temp) == “-1”) { field.value=(field.value.substring(0,i)+(field.value.substring(i+1,field.value.length))); i– } } } function validatenum3(field) { var valid = “0123456789,,,,.” var temp; for (var i=0; i<field.value.length; i++) { temp = “” + field.value.substring(i, i+1); if (valid.indexOf(temp) == “-1″) { field.value=(field.value.substring(0,i)+(field.value.substring(i+1,field.value.length))); i– } } } //–> </script>
    <script language=”JavaScript”> <!– function validate_ss(field) { var valid = “0123456789-” var temp; for (var i=0; i<field.value.length; i++) { temp = “” + field.value.substring(i, i+1); if (valid.indexOf(temp) == “-1″) { field.value=(field.value.substring(0,i)+(field.value.substring(i+1,field.value.length))); i– } } } //–> </script>
    <script language=”JavaScript”> <!– function validateposnum(field) { var valid = “0123456789.” var temp; for (var i=0; i<field.value.length; i++) { temp = “” + field.value.substring(i, i+1); if (valid.indexOf(temp) == “-1″) { field.value=(field.value.substring(0,i)+(field.value.substring(i+1,field.value.length))); i– } } } //–> </script>
    <script language=”JavaScript”> <!– function validateint(field) { var valid = “0123456789” var temp; for (var i=0; i<field.value.length; i++) { temp = “” + field.value.substring(i, i+1); if (valid.indexOf(temp) == “-1″) { field.value=(field.value.substring(0,i)+(field.value.substring(i+1,field.value.length))); i– } } } //–> </script>
    <script language=”JavaScript”> <!– function validateintsigned(field) { var valid = “-0123456789” var temp; for (var i=0; i<field.value.length; i++) { temp = “” + field.value.substring(i, i+1); if (valid.indexOf(temp) == “-1″) { field.value=(field.value.substring(0,i)+(field.value.substring(i+1,field.value.length))); i– } } } //–> </script>
    <script language=”Javascript1.1”> function imgchange(imgName,imgSrc) { if (document.images) { document.images[imgName].src = imgSrc; } } function imgchange2(imgName, imgSrc) { if (document.images) { document[imgName].src = eval(imgSrc + “.src”); } } </script>
    <title>NolaPro Business Management </title>
    <link type=”images/x-icon” href=”images/favicon.ico” rel=”SHORTCUT ICON”/>
    <div id=”overDiv” style=”position:absolute; visibility:hidden; z-index:1000;”/>
    <script src=”js/overlib.js” language=”JavaScript”/>
    <script language=”javascript”> var todayString = “Today is”; var monthName = new Array(“January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”); var monthName2 = new Array(“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”); dayName = new Array (“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”); //dayName = new Array (“Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”,”Sun”) </script>
    <link type=”text/css” rel=”stylesheet” href=”includes/default.css”/>
    <script language=”javascript”> var rs_debug_mode = false; function rs_debug(text) { if (rs_debug_mode) alert(“RSD: ” + text); } function rs_init_object() { rs_debug(“rs_init_object() called..”); var A; try { A=new ActiveXObject(“Msxml2.XMLHTTP”); } catch (e) { try { A=new ActiveXObject(“Microsoft.XMLHTTP”); } catch (oc) { A=null; } } if(!A && typeof XMLHttpRequest != “undefined”) A = new XMLHttpRequest(); if (!A) rs_debug(“Could not create connection object.”); return A; } // wrapper for findcust function x_findcust() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findcust”, a = x_findcust.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findcust url = ” + url); rs_debug(“x_findcust waiting..”); delete x; } // wrapper for finddelcustid function x_finddelcustid() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=finddelcustid”, a = x_finddelcustid.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_finddelcustid url = ” + url); rs_debug(“x_finddelcustid waiting..”); delete x; } // wrapper for findvendor function x_findvendor() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findvendor”, a = x_findvendor.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findvendor url = ” + url); rs_debug(“x_findvendor waiting..”); delete x; } // wrapper for finditemcode function x_finditemcode() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=finditemcode”, a = x_finditemcode.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_finditemcode url = ” + url); rs_debug(“x_finditemcode waiting..”); delete x; } // wrapper for finditemid function x_finditemid() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=finditemid”, a = x_finditemid.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_finditemid url = ” + url); rs_debug(“x_finditemid waiting..”); delete x; } // wrapper for finddelitemid function x_finddelitemid() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=finddelitemid”, a = x_finddelitemid.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_finddelitemid url = ” + url); rs_debug(“x_finddelitemid waiting..”); delete x; } // wrapper for findagent function x_findagent() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findagent”, a = x_findagent.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findagent url = ” + url); rs_debug(“x_findagent waiting..”); delete x; } // wrapper for findglaccount function x_findglaccount() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findglaccount”, a = x_findglaccount.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findglaccount url = ” + url); rs_debug(“x_findglaccount waiting..”); delete x; } // wrapper for findpo function x_findpo() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findpo”, a = x_findpo.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findpo url = ” + url); rs_debug(“x_findpo waiting..”); delete x; } // wrapper for findgroup function x_findgroup() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findgroup”, a = x_findgroup.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findgroup url = ” + url); rs_debug(“x_findgroup waiting..”); delete x; } // wrapper for findvendorterms function x_findvendorterms() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findvendorterms”, a = x_findvendorterms.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findvendorterms url = ” + url); rs_debug(“x_findvendorterms waiting..”); delete x; } // wrapper for findorder function x_findorder() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findorder”, a = x_findorder.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findorder url = ” + url); rs_debug(“x_findorder waiting..”); delete x; } // wrapper for findinvoice function x_findinvoice() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findinvoice”, a = x_findinvoice.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findinvoice url = ” + url); rs_debug(“x_findinvoice waiting..”); delete x; } // wrapper for finduser function x_finduser() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=finduser”, a = x_finduser.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_finduser url = ” + url); rs_debug(“x_finduser waiting..”); delete x; } // wrapper for findshipto function x_findshipto() { // count args; build URL var i, x, n; var url = “autofunctionsdb.php?rs=findshipto”, a = x_findshipto.arguments; for (i = 0; i < a.length-1; i++) url = url + “&rsargs[]=” + escape(a[i]); url = url + “&rsrnd=” + new Date().getTime(); x = rs_init_object(); x.open(“GET”, url, true); x.onreadystatechange = function() { if (x.readyState != 4) return; rs_debug(“received ” + x.responseText); var status; var data; status = x.responseText.charAt(0); data = x.responseText.substring(2); if (status == “-“) alert(“Error: ” + callback_n); else a[a.length-1](data); } x.send(null); rs_debug(“x_findshipto url = ” + url); rs_debug(“x_findshipto waiting..”); delete x; } var keystrokedelay=400; //Time in milliseconds to wait after a keystroke before //sending out a request var displaylistcount=0; //Number of auto-complete list currently open </script>
    <div align=”center”>
    <center>
    <table border=”0″ align=”center” cellspacing=”0″ cellpadding=”0″>
    <tbody>
    <tr>
    <td nowrap=””>
    <script language=”javaScript”> function changeFrames() { parent.frames[‘menu’].location = ‘sidemenu.php?index=0’; parent.frames[‘main’].location = ‘blank.php’; parent.frames[‘graphic’].location = ‘sidegraphic.php’; } </script>
    <center>
    <table border=”0″>
    <tbody>
    <tr>
    <td>
    <td>
    <td>
    <td>
    <td>
    <a onmouseover=”window.status=’Log Out of System’;return true;” href=”indexmain.php?logout=1″ target=”_top”>
    <img border=”0″ alt=”Logout” title=”Logout” src=”menuicons/3d/logout.png”/>
    </a>
    </td>
    </tr>
    </tbody>
    </table>
    <center>
    </center>
    </td>
    </tr>
    </tbody>
    </table>
    </center>
    </div>
    </body>
    </html>
    </document>

    on December 12, 2015.
    Add Comment

    You should learn about XPath before starting Automation with Selenium.

    Please go through this url: http://www.w3schools.com/xsl/xpath_intro.asp

    You could be able to create XPath for same object with different ways.

    Default Answered on December 8, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.