0

How can I use Selenium locators to find and click the Termination menu item below? It does not become visible until I've clicked through the parent menu items.

Page code:

<html>
<head>
<body>

<script src="/javalms/common/jscript/menu/menu_com.js" type="text/javascript">
<link href="/javalms/common/css/megamenu.css" type="text/css" rel="stylesheet">
<link href="/javalms/common/css/bootstrap-common.css" type="text/css" rel="stylesheet">
<script>
  Menu1= new Array('Authorizers Desk','','',3,ItemHeight,ItemWidth);      
  Menu1_1= new Array('Loan Processing','','',8,ItemHeight,ItemWidth); 
  Menu6= new Array('Processes','','',2,ItemHeight,ItemWidth); 
  Menu1_2= new Array('Settlements','','',7,ItemHeight,ItemWidth); 
  Menu5= new Array('References','','',1,ItemHeight,ItemWidth); 
  Menu4_4= new Array('DownLoads','','',1,ItemHeight,ItemWidth); 
  Menu1_1_3= new Array('Documents','','',2,ItemHeight,ItemWidth);  
  Menu3_11= new Array('NPA and Provisioning','','',4,ItemHeight,ItemWidth); 
  Menu4= new Array('Ops&Control','','',13,ItemHeight,ItemWidth); 
  Menu4_1= new Array('Reports','','',13,ItemHeight,ItemWidth); 
  Menu4_13= new Array('Unapplied Credit Reports','','',2,ItemHeight,ItemWidth); 
  Menu1_1_7= new Array('NPA and Provisioning','','',1,ItemHeight,ItemWidth); 
  Menu7=new Array('Help','javascript:openWindow()','',0,ItemHeight,37);
</script>
<script src="/javalms/common/jscript/Validation.js" type="text/javascript" language="JavaScript">
<script src="/javalms/common/jscript/SHA256.js" type="text/javascript" language="JavaScript">
<script src="/javalms/common/jscript/MDLogin.js" type="text/javascript" language="JavaScript">
<script src="/javalms/common/jscript/AlertFileen.js" type="text/javascript" language="JavaScript">
<link href="/javalms/common/css/LendingLTR.css" type="text/css" rel="stylesheet">
<script>
<script>
<script>
<input id="hidTimerCtr" type="hidden" name="hidTimerCtr" value="200">
<input id="hidTimerVal" type="hidden" name="hidTimerVal" value="1500">
<script>
<script src="/javalms/common/jscript/LovValidation.js" type="text/javascript" language="JavaScript">
<script src="/javalms/common/jscript/ChangeBranch.js" type="text/javascript" language="JavaScript">
<script language="javascript">
<style type="text/css">
<form action="/javalms/loginCheck.do" name="LoginAF" method="post">
<form action="/javalms/loginCheck.do" name="LoginAF" method="post">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<table width="100%">
<div bgcolor="#3993BA" orgleft="1" orgtop="80" style="Z-INDEX: 101; POSITION: absolute; BACKGROUND-COLOR: #3993ba; FONT-STYLE: normal; WIDTH: 1083px; FONT-FAMILY: sans-serif; HEIGHT: 28px; VISIBILITY: visible; FONT-SIZE: 9pt; TOP: 80px; FONT-WEIGHT: bold; LEFT: 1px">
<div orgleft="0" orgtop="28" style="Z-INDEX: 102; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 82px; VISIBILITY: visible; FONT-SIZE: 9pt; TOP: 108px; FONT-WEIGHT: bold; LEFT: 1px">
<div orgleft="172.27" orgtop="0" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 217px; VISIBILITY: visible; FONT-SIZE: 9pt; TOP: 108px; FONT-WEIGHT: bold; LEFT: 173px">
<div hifntclr="#ffffff" hibck="#336699" lwfntclr="#000000" lobck="#E6E6E6" value="Post Disbursal Edits" ro="0" hilite="0" childcntnr="null" linktxt="lms/loanprocessing/agreement/AgreementAC.do?mode=searchAgreement&makerchakerflag=C&activity=PDE&taskid=124" level="3" prvmbr="null" style="POSITION: absolute; TEXT-ALIGN: left; BACKGROUND-COLOR: #e6e6e6; PADDING-LEFT: 2px; WIDTH: 173px; HEIGHT: 26px; VISIBILITY: inherit; COLOR: #000000; OVERFLOW: hidden; TOP: 1px; CURSOR: hand; PADDING-TOP: 6px; LEFT: 1px">Post Disbursal Edits</div>
<div hifntclr="#ffffff" hibck="#336699" lwfntclr="#000000" lobck="#E6E6E6" value="Property Details" ro="0" hilite="0" childcntnr="null" linktxt="lms/loanprocessing/property/action/PropertyAC.do?makerchakerflag=C&taskid=127" level="3" style="POSITION: absolute; TEXT-ALIGN: left; BACKGROUND-COLOR: #e6e6e6; PADDING-LEFT: 2px; WIDTH: 173px; HEIGHT: 26px; VISIBILITY: inherit; COLOR: #000000; OVERFLOW: hidden; TOP: 28px; CURSOR: hand; PADDING-TOP: 6px; LEFT: 1px">Property Details</div>
<div hifntclr="#ffffff" hibck="#336699" lwfntclr="#000000" lobck="#E6E6E6" value="Documents" ro="0" hilite="0" linktxt="" level="3" style="POSITION: absolute; TEXT-ALIGN: left; BACKGROUND-COLOR: #e6e6e6; PADDING-LEFT: 2px; WIDTH: 173px; HEIGHT: 26px; VISIBILITY: inherit; COLOR: #000000; OVERFLOW: hidden; TOP: 55px; CURSOR: default; PADDING-TOP: 6px; LEFT: 1px">Documents</div>
<div hifntclr="#ffffff" hibck="#336699" lwfntclr="#000000" lobck="#E6E6E6" value="Cancellation" ro="0" hilite="0" childcntnr="null" linktxt="lms/loanprocessing/loancancellation/loanCancellationQueryAC.do?mode=OPEN&amp;mc=C&amp;op=LOANCANCEL&taskid=125" level="3" style="POSITION: absolute; TEXT-ALIGN: left; BACKGROUND-COLOR: #e6e6e6; PADDING-LEFT: 2px; WIDTH: 173px; HEIGHT: 26px; VISIBILITY: inherit; COLOR: #000000; OVERFLOW: hidden; TOP: 82px; CURSOR: hand; PADDING-TOP: 6px; LEFT: 1px">Cancellation</div>
<div hifntclr="#ffffff" hibck="#336699" lwfntclr="#000000" lobck="#E6E6E6" value="Rescheduling / Bulk Refund" ro="0" hilite="0" childcntnr="null" linktxt="lms/loanprocessing/agreement/AgreementAC.do?mode=searchAgreement&makerchakerflag=A&activity=RCHD&taskid=121" level="3" style="POSITION: absolute; TEXT-ALIGN: left; BACKGROUND-COLOR: #e6e6e6; PADDING-LEFT: 2px; WIDTH: 173px; HEIGHT: 26px; VISIBILITY: inherit; COLOR: #000000; OVERFLOW: hidden; TOP: 109px; CURSOR: hand; PADDING-TOP: 6px; LEFT: 1px">Rescheduling / Bulk Refund</div>
<div hifntclr="#ffffff" hibck="#336699" lwfntclr="#000000" lobck="#E6E6E6" value="Termination" ro="0" hilite="0" childcntnr="null" linktxt="util/listViewQueryAC.do?mode=OPEN&amp;mc=C&amp;op=T&amp;ot=FD&taskid=122" level="3" style="POSITION: absolute; TEXT-ALIGN: left; BACKGROUND-COLOR: #e6e6e6; PADDING-LEFT: 2px; WIDTH: 173px; HEIGHT: 26px; VISIBILITY: inherit; COLOR: #000000; OVERFLOW: hidden; TOP: 136px; CURSOR: hand; PADDING-TOP: 6px; LEFT: 1px">Termination</div>
<div hifntclr="#ffffff" hibck="#336699" lwfntclr="#000000" lobck="#E6E6E6" value="NPA and Provisioning" ro="0" hilite="0" linktxt="" level="3" style="POSITION: absolute; TEXT-ALIGN: left; BACKGROUND-COLOR: #e6e6e6; PADDING-LEFT: 2px; WIDTH: 173px; HEIGHT: 26px; VISIBILITY: inherit; COLOR: #000000; OVERFLOW: hidden; TOP: 163px; CURSOR: default; PADDING-TOP: 6px; LEFT: 1px">NPA and Provisioning</div>
<div hifntclr="#ffffff" hibck="#336699" lwfntclr="#000000" lobck="#E6E6E6" value="Asset Details-Info Updation" ro="0" hilite="0" childcntnr="null" linktxt="lms/loanprocessing/assetdetails/assetinformation/jsp/AssetInformationQuery.do?method=menu&mode=A&taskid=137" level="3" style="POSITION: absolute; TEXT-ALIGN: left; BACKGROUND-COLOR: #e6e6e6; PADDING-LEFT: 2px; WIDTH: 173px; HEIGHT: 26px; VISIBILITY: inherit; COLOR: #000000; OVERFLOW: hidden; TOP: 190px; CURSOR: hand; PADDING-TOP: 6px; LEFT: 1px">Asset Details-Info Updation</div>
</div>
<div orgleft="172.27" orgtop="54" style="Z-INDEX: 104; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 55px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="162" style="Z-INDEX: 104; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 28px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="27" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 190px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="174" orgtop="28" style="Z-INDEX: 102; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 109px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="0" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 55px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="348" orgtop="28" style="Z-INDEX: 102; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 298px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="0" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 28px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="54" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 55px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="108" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 190px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="162" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 82px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="270" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 109px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="522" orgtop="28" style="Z-INDEX: 102; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 366px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="0" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 352px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="0" style="Z-INDEX: 104; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 28px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="27" style="Z-INDEX: 104; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 109px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="54" style="Z-INDEX: 104; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 28px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="81" style="Z-INDEX: 104; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 82px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="81" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 28px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="172.27" orgtop="338" style="Z-INDEX: 103; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 55px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="696" orgtop="28" style="Z-INDEX: 102; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 28px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
<div orgleft="870" orgtop="28" style="Z-INDEX: 102; POSITION: absolute; FONT-STYLE: normal; WIDTH: 175px; FONT-FAMILY: sans-serif; HEIGHT: 55px; VISIBILITY: hidden; FONT-SIZE: 9pt; TOP: 0px; FONT-WEIGHT: bold; LEFT: 0px">
</body>
</html>

Screenshot: enter image description here

2

The scenario to deal with this kind of element is

  1. Click on Menu element, submenu get visible now
  2. Click on submenu now

So tho handle this you have to use Actions class. Use below example to handle the same :

WebElement menu = driver.findElement(By.your_locatorForMenuElement);
WebElement submenu = driver.findElement(By.your_locatorForMenuElement);

Actions action = new Actions(driver);
action.moveToElement(menu).clickAndHold(submenu).click().build().perform(); 

Let me know if you have any trouble.

6
  • OP didn't specify language, but +1 for the good java example, although I'm not clear on why you need to click an hold? – mrfreester Sep 8 '17 at 14:23
  • Thnx narendra, it worked for me, but sometimes it losses menu focus because of this some other element gets click. – Yash Shrivastava Sep 13 '17 at 8:56
  • @YashShrivastava, If this answer is helpful for you then do not forget to Accept by click on right tick below vote count. it may helpful for others. Thanks :) – NarendraR Sep 13 '17 at 10:48
  • @NarendraRajput yes its working now thnx, i also would like to ask u how to find value from nested <div> or nested <frameset> example code are:: <div bgcolor="#3993BA" orgleft="1" orgtop="80" style="Z-INDEX: 101; POSITION: absolute; BACKGROUND-COLOR: #3993ba; FONT-STYLE: normal; WIDTH: 1083px; FONT-FAMILY: sans-serif; HEIGHT: 28px; VISIBILITY: visible; FONT-SIZE: 9pt; TOP: 80px; FONT-WEIGHT: bold; LEFT: 1px"> <div><div><div><div><div><div><div><div><div><div> – Yash Shrivastava Sep 13 '17 at 10:56
  • @YashShrivastava, here I'm not seeing any element in your posted code. even you can get the nested things by text too. e.g. here you want to get Termination witch is under div tag so just make xpath like //div[contains(text(),'Termination')] – NarendraR Sep 13 '17 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.