VBA Excel - Filling in webforms unable to click submit button - excel

I am fairly new to coding and took on this project to create 1000 new accounts in an internal program we have at my work. I was able to get the macro to fill in the webform and proceed through 2 pages however at the third page I was unable to get it to click the submit button.
Code:
Sub Automate1()
Dim IE As Object
Dim doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://associate.heritagerep.com/signup/signup.asp?
SectionID=10&t=10030&guid=CB57C450-F8D2-4644-98CB-99C37DA43668"
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set doc = IE.document
'First Screen'
doc.getElementsByName("sponsor")(0).Value = "kffrep"
doc.getElementById("Username").Value = "75871"
doc.getElementById("email").Value = "75871#kff.com"
doc.getElementById("zip").Value = "111111"
doc.getElementsByName("Submit")(0).Click
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Second Screen'
doc.getElementById("companyName").Value = "kff1"
doc.getElementById("OccupationTy_Select").Value = 34
doc.getElementById("fname").Value = "75871"
doc.getElementById("lname").Value = "kff1"
doc.getElementById("mstreet1").Value = "1 kff st"
doc.getElementById("mcity").Value = "Mississauga"
doc.getElementById("mstate").Value = "ON"
doc.getElementById("hphone").Value = "1111111"
doc.getElementById("emailConfirm").Value = "75871#kff.com"
doc.getElementsByName("SSN")(0).Value = "000000000"
doc.getElementById("password").Value = "password1"
doc.getElementById("passwordconfirm").Value = "password1"
doc.getElementsByName("securityanswer")(0).Value = "pizza"
doc.getElementsByClassName("btn btn-primary")(0).Click
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Third Screen'
Set tags = doc.getElementsByClassName("btn btn-success")
For Each tagx In tags
If tagx.Name = "submitfinish" Then
tagx.Click
End If
Next
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Fourth Screen'
doc.getElementsByName("Submit3")(0).Click
'Fifth Screen'
doc.getElementsByName("CheckOrderPaid")(0).Click
doc.getElementsByName("Shipped")(0).Click'
doc.getElementsByName("subAdminOpt")(0).Click
Flag
End Sub
Below is the HTML code for the troublesome button:
<input name="submitfinish" class="btn btn-success" type="submit" value="Finish Order">
I am not sure why the actions I used in the first 2 pages to click the submit button are suddenly not working on the third page. I have tried may different iterations trying to work around the problem but have yet to find one that is successful.
Appreciate any feedback.
Additional DOM Details:
<div class="text-right">
<a class="btn btn-default" href="/default.asp?guid=651F5B01-725B-4CCD-B12E-17CD5D59C472">Continue Shopping<!--Continue Shopping--></a>
<input name="submitcalc" class="btn btn-default" type="submit" value="Re-Calculate">
<input name="submitfinish" class="btn btn-success" type="submit" value="Finish Order"><!--Finish Order -->
</div>
Entire webpage HTML:
<!DOCTYPE html>
<html lang="en" class="non-mobile">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<meta content='width=device-width, initial-scale=1.0, maximum-
scale=1.0, user-scalable=0' name='viewport' />
<!-- Scripts -->
<script type="text/javascript" src="//code.jquery.com/jquery-
1.11.0.min.js"></script>
<script type="text/javascript" src="/common/script.js"></script>
<script type="text/javascript" src="/common/function/script_source.js"></script>
<script type="text/javascript" src="/common/jquery/jquery.validate.min.js"></script>
<script type="text/javascript" src="/common/function/functions.js"></script>
<!-- bootstrap -->
<script type="text/javascript" src="/responsive/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/responsive/js/common.js"></script>
<script type="text/javascript" src="/common/shadowbox/shadowbox.js"></script>
<script type="text/javascript" src="/responsive/js/jquery.animate-colors-min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.js"></script>
<script type="text/javascript" src="//unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<!-- CSS -->
<link href="/common/shadowbox/shadowbox.css" rel="stylesheet">
<link href="/responsive/css/bootstrap.css" rel="stylesheet">
<link href="/responsive/css/bootstrap-custom.css" rel="stylesheet">
<link href="/responsive/css/bootstrap-ms.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.css" rel="stylesheet">
<!-- Parent Site overrides -->
<link href="//associate.heritagerep.com/clientinc/resources/css/common.css" rel="stylesheet">
<style type="text/css">
#import url('//associate.heritagerep.com/common/templates/public/css/custom.css');
</style>
<script type="text/javascript">
$(function() {
app.init({ domain: 'associate.heritagerep.com'});
});
</script>
</head>
<body class="responsive">
<!-- This is a helper so javascript can see whether or not this is a mobile device -->
<div id="isMobile" class="visible-xs"></div>
<form method="post" name="currencyty">
<input type="hidden" name="CartId" value="439915">
<table class="table table-striped">
<thead>
<tr>
<th>ItemCode<!--ItemCode--></th>
<th>Description<!--Descr--></th>
<th>Qty<!--Qty--></th>
<th>Currency<!--Currency--></th>
<th>Price Each<!--Price Each--></th>
<th>
Volume
</th>
<th>Volume 2<!--Volume 2--></th>
<th>Price Total<!-- Total--></th>
<th>
Points Total
</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td> <!-- ITEM CODE -->
1004
</td>
<td><!-- Description -->
Initial Certification Fee
</td>
<td> <!-- QTY -->
<input name="Qty_609000021&609000020&0&-1&1004&N" type="text" value="1" size="2" onblur="WidthTest(this,1);" />
</td>
<td>CAD</td>
<td>
$25.00
</td>
<td>
0
</td>
<td>
0
</td>
<td>
$25.00
</td>
<td>
0
</td>
<td class="text-right">
Edit<!--Edit-->
</td>
</tr>
<tr>
<td colspan="100%">
<div class="pull-left">
Add Item<!--Add-->
</div>
<div class="pull-right">
<input name="adItemCode" type="text" value="Item Code" size="10" onclick="this.value = ''" onblur="WidthTest(this,1);AddTableRow('ProductItemCode')"><!--Item Code-->
Qty:<!--Qty:--> <input name="adNewQty" type="text" value="1" size="2" onblur="WidthTest(this,1);">
<span style="font-weight:bold;vertical-align: middle; float: right;">
<input type="submit" name="submitadd" value="Add Item" onclick="whichButton='add';"><!--Add Item-->
</span>
</div>
</td>
</tr>
</tbody>
</table>
<div class="pull-right">
<ul class="list-group">
<li class="list-group-item">
<strong>Volume:</strong>
0
</li>
<li class="list-group-item">
<strong>Totals<!--Totals :-->:</strong>
$25.00
</li>
</ul>
</div>
<div class="clearfix"></div>
<div class="text-right">
Continue Shopping<!--Continue Shopping-->
<input type="submit" name="submitcalc" value="Re-Calculate" class="btn btn-default">
<input type="submit" name="submitfinish" value="Finish Order" class="btn btn-success"><!--Finish Order -->
</div>
</form>
<script language="javascript">
$(function() {
$('.fancy').fancybox({
'width' : '75%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe',
'topRatio': '0.1',
'autoHeight': true
});
});
</script>
</body>

You could try and attribute = value selector to target element. Let us know if an error and if so check if there is a parent iframe/frame tag.
ie.document.querySelector("[value='Finish Order']").click
Or
ie.document.querySelector("[value='Finish Order']").FireEvent "onclick"

Related

Using VBA to click a javascript link, get "object required" error

I am attempting to access a website on IE using VBA to pull a report of the previous weeks transactions. I was able to login and navigate to the report page. However, when I try to click a link for an advanced search I get the error "Object Required"
Below is the HTML I have isolated as belonging to the link:
<!-- Form Actions -->
<input type="button" id="searchtTxn" value="Search"
class="align-right margin-top"
style="float: right; font-size: 11px; margin-top: 5px;">
**<div id="secondary-button"
style="border: none; background: none; height: 26px; font-size: 11px; float: right;">
<a href="javascript:void(0);" id="moreOptions" class="mouseover"><strong>More
Options</strong>**
</a>
</div>
Specifically, I am trying to select the "moreOptions" item. I have also tried selecting based on the "mouseover" class with no luck. I also tried to create a saved report that I could just click based on the class and ID, the HTML for this search is below:
<div class="div-scroll portletContentJS"
style="height:145px !important;" id="savedSearchPortlet"
style="overflow-y: auto;">
<div class="savedsearch-record">
<table style="width:100%;" class='draggable' >
<tr>
<td class="wrap-savedsearch-report">
<div class="constrained">
<a href="javascript:void(0);" class="searchtResultTxn hasTooltip"
id="164035" style="text-decoration: underline;font-size:11px; padding-left: 2px;">Prev Week ACH </a>
<div class="hidden">
<!-- This class should hide the element, change it if needed -->
<table>
<tr>
<td style='word-wrap:break-word;word-break:break-all;max-width:150px;min-width:50px;'>Prev Week ACH</td>
</tr>
</table>
</div>
I am using the below VBA to access the website and navigate to the page I need. The code errors out when I try to pull the Element "moreOptions". I built in a 20 second wait time on the page that doesn't work in case the link wasn't available yet to no avail. I have gone as high as 1 minute with no results.
Sub login1()
Dim IE As Object
Dim HTMLDoc As Object
Dim objCollection As Object
Dim allHREFs As New Collection
Const navOpenInNewTab = &H800
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "https://www.treasury.pncbank.com/idp/esec/login.ht"
Do While IE.Busy Or IE.readyState <> 4: Loop
Set HTMLDoc = IE.Document
With HTMLDoc
HTMLDoc.getElementById("txtUserID").value = "XXXX"
HTMLDoc.getElementById("txtOperID").value = "XXXXXX"
HTMLDoc.getElementById("txtPwd").value = "XXXXXX"
End With
Set objCollection = IE.Document.getElementById("loginFormButton")
objCollection.Click
Do While IE.Busy Or IE.readyState <> 4: Loop
Application.Wait (Now + TimeValue("0:00:10"))
Set objCollection = IE.Document.getElementById("IR")
objCollection.Click
Application.Wait (Now + TimeValue("0:01:00"))
Set objCollection = IE.Document.getElementById("moreOptions")
objCollection.Click
Do While IE.Busy Or IE.readyState <> 4: Loop
End Sub
Any help here would be greatly appreciated. Please let me know if you need additional details. As it is a banking website I will not be able to provide login credentials but let me know if you need more of the HTML code.
EDIT to Add Full Page HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PINACLE - PNC</title>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE;"/>
<style>
#import "/portal/shared/style/new-navigation/stylesheet.css";
#import "/portal/shared/style/new-navigation/navbar.css";
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/portal/shared/js/jQuery/jQuery.min.js"></script>
<script type="text/javascript" src="/portal/shared/js/jQuery/jquery-migrate.min.js"></script>
<!-- TeaLeaf config file needs to come before SDK -->
<script type="text/javascript" src="/portal/service/js/TealeafSDKConfig.js"></script>
<script type="text/javascript" src="/portal/service/js/TealeafSDK.js"></script>
<script type="text/javascript" src="/portal/shared/js/dojotoolkit/dojo/dojo.js"
djConfig="parseOnLoad:true"></script>
<script type="text/javascript" src="/portal/shared/js/dojotoolkit/dojo/portal.js"></script>
<script type="text/javascript" src="/portal/shared/js/common/navigation.js"></script>
<!-- Carousel - Navigation -->
<script type="text/javascript" src="/portal/shared/js/newPrimaryNav/navbar.js"></script>
<script type="text/javascript" src="/portal/shared/js/newPrimaryNav/jquery.tinycarousel2.js"></script>
<!-- End Carousel - Navigation -->
<!-- Draggable -->
<script type="text/javascript" src="/portal/shared/js/newPrimaryNav/jquery-ui.min.js"></script>
<script type="text/javascript" src="/portal/shared/js/newPrimaryNav/draggable.js"></script>
<link rel="stylesheet" href="/portal/shared/style/jquery-ui.css">
<!-- End Draggable -->
<script type='text/javascript' src='/portal/shared/js/engine.js'></script>
<script type='text/javascript' src='/portal/shared/js/util.js'></script>
<script type='text/javascript' src='/portal/dwr/interface/PortletDisplayHelper.js'></script>
<script type='text/javascript' src='/portal/dwr/interface/AjaxSessionManager.js'></script>
<SCRIPT LANGUAGE="JScript" TYPE="text/javascript">
</SCRIPT>
<script type="text/javascript">
(function() {
var host = '/tmmps/payee.js';
var sn = document.createElement('script');
sn.setAttribute('async', true);
sn.setAttribute('type', 'text/javascript');
sn.setAttribute('src', host);
var s = document.getElementsByTagName('head')[0];
s.appendChild(sn);
})();
</script>
<!-- Add meta tag to enable PINACLE Smart App Banner on mobile devices -->
<script type="text/javascript">
if ( /(iPad).*AppleWebKit.*Mobile.*Safari/.test(navigator.userAgent) ) {
var headNode = document.getElementsByTagName("head")[0];
var sbNode = document.createElement('meta');
sbNode.name = 'apple-itunes-app';
sbNode.content = 'app-id=804888748';
headNode.appendChild(sbNode);
} else if ( /(iPhone|iPod).*AppleWebKit.*Mobile.*Safari/.test(navigator.userAgent) ) {
var headNode = document.getElementsByTagName("head")[0];
var sbNode = document.createElement('meta');
sbNode.name = 'apple-itunes-app';
sbNode.content = 'app-id=874929964';
headNode.appendChild(sbNode);
}
</script>
<!-- Set the required variables for Web Analytics -->
<script type="text/javascript">
var page_data = {
"site_name" : "pin",
"language" : "en",
"brandname" : "PINACLE",
"page_name" : "dashboard",
"page_type" : "",
"user_type" : "",
"page_error" : [],
"events" : []
};
<!-- Set the required theme values for EN Alerts -->
var delay = setSecond(5);
var mcSrc = '/portal/isc/ITS?svcnum=410&lte=999&relayState=newMessage&sky=xGTwyoiPngrh1eNFu3twqg%3d%3d';
</script>
<script id="pendo-snippet">
var pendoFlag = 'Y';
var pendoKey = '67a13df9-2e80-4942-4c32-6c799c2b8a67';
var pendoUrl = 'https://cdn.pendo.io/agent/static/';
var account = '10bf187d:013aea5bee72:50e1:01161136';
var visitor = '08757603:016a2273446c:442c:7922f8fb';
if(pendoFlag != null && pendoFlag == 'Y' ){
(function(apiKey){
(function(p,e,n,d,o){var v,w,x,y,z;o=p[d]=p[d]||{};o._q=[];
v=['initialize','identify','updateOptions','pageLoad'];for(w=0,x=v.length;w<x;++w)(function(m){
o[m]=o[m]||function(){o._q[m===v[0]?'unshift':'push']([m].concat([].slice.call(arguments,0)));};})(v[w]);
y=e.createElement(n);y.async=!0;y.src=pendoUrl+apiKey+'/pendo.js';
z=e.getElementsByTagName(n)[0];z.parentNode.insertBefore(y,z);})(window,document,'script','pendo');
// Call this whenever information about your visitors becomes available
// Please use Strings, Numbers, or Bools for value types.
pendo.initialize({
visitor: {
id: visitor
},
account: {
id: account
}
});
})(pendoKey);
}
</script>
<!-- DTM tag for Web Analytics -->
<script type="text/javascript" src="//assets.adobedtm.com/1d90950c926aacaf003e1e8e48aeb1189d4d7901/satelliteLib-da0748631f5bf7f81de415cc298c402328aca822.js"></script>
</head>
<body class="tundra" style="margin: 0px; overflow:hidden;">
<form name="frmLogOut" id="frmLogOut" method="post" action="/idp/esec/logout.ht">
<input type="hidden" name="CST" id="CST" value="yQiJd0LUsfLawQPn9hibYKYebvjqQN2ek5F3WIO-Q6s"/>
</form>
<form name="pinacleMenuForm" method="post" action="/portal/isc/ITS" target="contentIframe">
<input type="hidden" name="svcnum" value=""/>
<input type="hidden" name="lte" value=""/>
<input type="hidden" name="relayState" value=""/>
<input type="hidden" name="sky" value=""/>
<input type="hidden" id="isLogoutProcessStart" name="isLogoutProcessStart" value="false"/>
</form>
<div id="portal-area">
<div id="newNavContainer">
<a id="logo" class="logostyle" target="_top">
<img src='/portal/shared/images/logo_PINACLE.png?05222010' title='PINACLE Home' />
</a>
<div class="utilitybar">
<input type="hidden" id="isLogoutProcessStart" value="false"/>
<!-- Start of Utility bar -->
<div id="utilityMenu" class="noarrow"><a id='LOUT'
href='/portal/esec/logout.ht~popup=N'">
Log Out</a>
</div>
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<div id="utilityMenu" class="noarrow"><a id='HELP'
href='/portal/isc/ITS?svcnum=615&lte=999&relayState=Admin&sky=n9wMfSLEaF8Tq%2Bq7BKeC%2BKOSkpw%3D~popup=N'">
Help & Training</a>
</div>
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<!-- Quick Links menu -->
<div class="arrow"><span class="top-levelQL">Quick Links</span>
<div class="dropdown">
<div id="utilityMenuQL">
<a id="HOME" href="https://www6.rbc.com/nj00-wcm/~popup=Y" target="_top">
Canada Express</a>
</div>
</div>
</div>
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<div id="cntsMenu" class="arrow" >
<span class="top-levelCNTS">Contact Us</span>
<div class="dropdown">
<div class="contact-separator" id="utilityMenuCNTS"><a id='PNE' href='/portal/isc/ITS?svcnum=110&lte=32&relayState=Normal Login&sky=hFBb%2BFaxIE2mbqyXUPb4QI8ujhw%3D~popup=N'
target="_top">Phone & Email</a>
</div>
</div>
</div>
<!-- End of Contact Us menu -->
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<div id="mcMenu" class="arrow">
<span class="top-levelMC">Message Center</span>
<div class="dropdown">
<div id="utilityMenuMC"><a id='MC' href='/portal/isc/ITS?svcnum=410&lte=999&relayState=managerUser&sky=zUUFoarcvOhT%2BHZsvYhGUxdTrMY%3D~popup=N'
target="_top">View Messages</a>
</div>
<div id="utilityMenuMC"><a id='EVXCN' href='/portal/isc/ITS?svcnum=411&lte=999&relayState=normalLogin&sky=WYvYvPEHQiONA%2FJVJ6Nv2ixnfgc%3D~popup=N'
target="_top">Create Notifications</a>
</div>
<div id="utilityMenuMC"><a id='EVXMN' href='/portal/isc/ITS?svcnum=411&lte=999&relayState=evxMngNotifications&sky=14NR7J0sK%2F%2BOBBwvjZ2KL4sccxE%3D~popup=N'
target="_top">Manage Notifications</a>
</div>
</div>
</div>
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<div id="utilityMenu" class="noarrow"><a id='PROF'
href='/portal/isc/ITS?svcnum=120&lte=779&relayState=Admin&sky=XLwwWwsdoebibPHq17ltTwMaQRY%3D~popup=N'">
My Profile</a>
</div>
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<input type="hidden" id="homemenuurl" value="/portal/shared/js/dashboard/dashboard.html" />
<div id="utilityMenu" class="noarrow"><a id='HOME'
href='/portal/shared/js/dashboard/dashboard.html~popup=N'">
Home</a>
</div>
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
</div>
<div class="clear"></div>
<div id="mcSecurityCenter" class="securitycenter">
<a href='/portal/isc/ITS?svcnum=-201&tgt=L1BOU1dlYi9zaG93L2NvbnRlbnQvdHlwZS9TZWN1cml0eQ==~popup=N'
target="_top">
<img src='/portal/shared/images/shield.gif'
alt="Security Center" title="Security Center"/></a>
</div>
</div>
<div id="navbar">
<input type="hidden" id="keepaliveuri" value='/portal/modulecontainer/keepmealive.ht'/>
<a class="buttons prev" href="#"></a>
<div id="tabs" class="viewport">
<ul class="overview ui-sortable" id="sortable">
<li class="border-right"><a class="cursor" id='IR' menuId = '11084'
href="/portal/isc/ITS?svcnum=277&lte=999&relayState=normalLogin&sky=M2ePfNeGG85McrNpd8XuyGxkYTg%3D~popup=N" text="Information Repting" onClick="pendoFunction('')" >
<span class="center-align">
Information <br> Reporting
</span>
</a>
<div id="keepaliveind" data="N"></div>
</li>
<li class="border-right"><a class="cursor" id='SRS' menuId = '35'
href="/portal/isc/ITS?svcnum=966&lte=999&relayState=normalLogin&sky=U9HtsOKdAoQPfjSFA2vaeecoieQ%3D~popup=N" text="Spl Rpts Svc" onClick="pendoFunction('')" >
<span class="center-align">
Special <br> Reports
</span>
</a>
<div id="keepaliveind" data="N"></div>
</li>
</ul>
</div>
<a class="buttons next" href="#"></a>
</div>
<div class="navbar-divider"></div>
<div id="blankDivIR" style="height:0px;width:100%">
<iframe id='blankiframeIR' style='width:100%;height:0px'
scrolling="NO" noresize marginwidth="0" marginheight="0" frameborder="0"
src='/ir/irOpeningPage/initialize.htm'>
</iframe>
</div>
<div id="blankDiv" style="height:0px;width:100%">
<iframe id='blankiframe' style='width:100%;height:0px'
scrolling="NO" noresize marginwidth="0" marginheight="0" frameborder="0"
src='/portal/isc/blank.jsp'>
</iframe>
</div>
<div id="pingRequestsDiv" style="height:0px;width:100%">
<iframe id='pingRequestsiframe' style='width:100%;height:0px'
scrolling="NO" noresize marginwidth="0" marginheight="0" frameborder="0"
src='/idp/pingRequests.ht'>
</iframe>
</div>
<div id="alertDiv" style="height:0px;width:100%">
<iframe id='alertiframe' style='width:100%;height:0px'
scrolling="NO" noresize marginwidth="0" marginheight="0" frameborder="0"
src='/portal/isc/blank.jsp'>
</iframe>
</div>
<div id="contentDiv" style="height:87%;width:100%">
<iframe id='contentIframe' name='contentIframe' style='height:100%;width:100%'
marginwidth="0" marginheight="0" frameborder="0"
src='/portal/shared/js/dashboard/dashboard.html'>
</iframe>
</div>
<div id="dialog-confirm" title="Session About To Expire" style="display: none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:12px 12px 20px 0;border-color: #334455"></span>Your PINACLE session is going to expire. Do you want to extend it ?</p>
</div>
<div id="dialog-confirm-non-pnc" title="Session About To Expire" style="display: none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:12px 12px 20px 0;border-color: #334455"></span>Your session is going to expire. Do you want to extend it ?</p>
</div>
</div>
</div>
<!-- Footer tag for Web Analytics -->
<script type="text/javascript">_satellite.pageBottom();</script>
<script type="text/javascript" >var _cf = _cf || []; _cf.push(['_setFsp', true]); _cf.push(['_setBm', true]); _cf.push(['_setAu', '/resources/54334735b2196aff2ba74ad5d5844c']); </script><script type="text/javascript" src="/resources/54334735b2196aff2ba74ad5d5844c"></script></body>
</html>
I was able to determine that the "moreOptions" element is inside of
the iFrame, I edited my original message to pull in the full HTML for
the page. I see that the "IR" element is outside of the iFrame.
To access the elements located inside the tag, we have to find the iframe tag first, then access the elements. You try to use the following code to get elements from the Iframe:
IE.Document.getElementsbyTagName("iframe")(0).contentDocument.getElementbyId("txtcontentinput").Value = "BBB"
IE.Document.getElementsbyTagName("iframe")(0).contentDocument.getElementbyId("btncontentSayHello").Click
[Note] The array index starts from 0. If the website contains multiple iframe tag, make sure using the right array index. Also, you could use the getElementbyId() method to find the iframe tag.
Detail sample code as below:
index page:
<input id="txtinput" type="text" /><br />
<input id="btnSayHello" type="button" value="Say Hello" onclick="document.getElementById('result').innerText = 'Hello ' + document.getElementById('txtinput').value" /><br />
<div id="result"></div><br />
<iframe width="500px" height="300px" src="vbaiframecontent.html">
</iframe>
vbaframeContent.html
<input id="txtcontentinput" type="text" /><br />
<input id="btncontentSayHello" type="button" value="Say Hello" onclick="document.getElementById('content_result').innerText = 'Hello ' + document.getElementById('txtcontentinput').value" /><br />
<div id="content_result"></div>
The VBA script as below:
Sub extractTablesData1()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate ("<your website url>")
While IE.ReadyState <> 4
DoEvents
Wend
'access elements outside the iframe tag and set value.
IE.Document.getElementbyId("txtinput").Value = "AAA"
IE.Document.getElementbyId("btnSayHello").Click
'access elements inside the iframe tag.
IE.Document.getElementsbyTagName("iframe")(0).contentDocument.getElementbyId("txtcontentinput").Value = "BBB"
IE.Document.getElementsbyTagName("iframe")(0).contentDocument.getElementbyId("btncontentSayHello").Click
End With
Set IE = Nothing
End Sub
After running the script, the result as below:

VBA .innertext using getelements*, cannot locate areas in html code

I am trying to create a macro to get the innertext from an internal webpage. I am not sure on how to properly locate the where the text is and would appreciate some direction and possibly some explanation on the approach.
I have tried numerous variations of using the getelementsby/tagname/classname to no avail. im not sure i understand the logic behind locating the areas after using the inspection function.
Var = ie.document.getelementClassName("sections").getElementsByTagName("table").Item(0).innerText
'also tried
Var = ie.document.getelementClassName("sections").getElementsByTagName("table").Item(1).getElementsByTagName("tr").Item(2).getElementsByTagName("td").Item(0).innerText
Var = ie.document.getelementTagName("section").getElementsByTagName("table").Item(1).getElementsByTagName("tr").Item(2).getElementsByTagName("td").Item(0).innerText
ActiveCell.Offset(0, 1).Value = Var
<html class=" js flexbox canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface no-generatedcontent video audio localstorage sessionstorage webworkers no-applicationcache svg inlinesvg smil svgclippaths" lang="" style=""><!--<![endif]--><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>NTC Tracking</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="stylesheet" href="/Content/bootstrap.min.css">
<!-- <link rel="stylesheet" href="~/Content/bootstrap-theme.min.css">-->
<!--For Plugins external css-->
<link rel="stylesheet" href="/Content/plugins.css">
<!--Theme custom css -->
<link rel="stylesheet" href="/Content/style.css">
<!--Theme Responsive css-->
<link rel="stylesheet" href="/Content/responsive.css">
<script src="/Scripts/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
</head>
<body data-spy="scroll" data-target="#main-navbar">
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please upgrade your browser to improve your experience.</p>
<![endif]-->
<div class="preloader" style="display: none;"><div class="loaded" style="display: none;"> </div></div>
<div id="menubar" class="main-menu">
<nav class="navbar-default navbar-fixed-top" style="background-color:#ffc038; padding:20px;">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="" href="http://10.102.18.162/"><img src="/images/msjlogo.png" style="max-width:50%; margin-top:-20px;"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><span style="font-weight:100; font-size:10px;">Proxy Plus(5/22/2019 8:20:00 AM) | IQ(5/22/2019 8:31:00 AM) | Vendors(5/21/2019 2:24:00 PM) | USPS(5/22/2019 8:43:00 AM) | International(5/21/2019 2:24:00 PM)</span></li>
</ul>
</div><!-- /.navbar-collapse -->
<div>
<a class="navbar-brand" href="/"><h3>NTC Tracking</h3></a>
</div>
<div style="clear:both; margin-bottom:20px;"></div>
<div>
</div>
</div><!-- /.container-fluid -->
</nav>
</div>
<!--Home page style-->
<header id="home" class="sections">
</header>
<!-- Sections -->
<header id="home">
<div class="container">
<h2 align="center">Search Job</h2>
<div class="col-md-6 col-md-offset-3 col-sm-6 col-xs-12">
<p align="center">Description of this view, testing space and top bar at the same time</p>
<p align="center">There are some hiding fields due to the web space, if you want to see them click on export</p>
<p align="center">Description of this view, testing space and top bar at the same time</p>
<p align="center">Description of this view, testing space and top bar at the same time</p>
</div>
</div>
<br>
</header>
<section class="sections">
<div class="portfolio">
<div align="center" class="portfolio-item">
<h5 align="center">Job Number </h5><input id="PPNumber" name="PPNumber" type="text" value="P23315"><br>
<a onclick="submitdata();" href="#" class="btn btn-primary">Search </a>
<br><br>
<div>
<p></p>
</div>
<div style="float:left"><h3 align="left">JOB</h3></div>
<table class="table" style="font-size:11px;">
<tbody><tr>
<th>
Job #
</th>
<th width="20%">
Job Name
</th>
<th>
MeetingDate
</th>
<th>
DropDate
</th>
<th>
NTCMailDate
</th>
<th>
LI#
</th>
<th>
Total Pieces
</th>
<th width="5%">
Day 40 On
</th>
<th width="5%">
Logistics Processed
</th>
<th width="5%">
IQ Status
</th>
<th>
MustMail Comments
</th>
<th>
Total Batch Completed
</th>
<th>
Actual Status
</th>
<th>
Options
</th>
</tr>
<tr>
<td>
P23315-010 </td>
<td width="20%">
ATLANTICA YIELD PLC <----****I NEED THIS****
</td>
<td>
6/20/2019
</td>
<td>
5/13/2019
</td>
<td>
5/13/2019
</td>
<td>
LI-8154090
</td>
<td>
2200
</td>
<td width="5%">
5/11/2019
</td>
<td width="5%">
4386
</td>
<td width="5%">
Mailed
</td>
<td>
MUST MAIL 5/14
</td>
<td>
11 out of 11
</td>
<td>
Foreign Client
</td>
<td>
<a class="btn btn-default" href="/Report/Reopenjob?jobnumber=P23315&jobref=P23315-010">Reopen Job</a>
</td>
</tr>
</tbody></table>
<br>
<br>
</div>
</div>
</section>
<script>
function submitdata(){
var valtext = $("#PPNumber").val();//you can do also by getelementbyid
window.location.href = '/Report/Search/' + valtext;
}
function ShowMessage() {
var result = prompt("Please insert a comment if required.", "");
if (result == null) {
return false; //break out of the function early
}
document.getElementById('comments').value = result;
return true;
}
</script>
<div class="scroll-top">
<div class="scrollup">
<i class="fa fa-angle-double-up"></i>
</div>
</div>
<!--Footer-->
<footer id="footer" class="footer">
<div class="container">
<div class="row">
<div class="socio-copyright">
<div class="social">
</div>
<p>Made by Broadridge 2017. All rights reserved.</p>
</div>
</div>
</div>
</footer>
<script src="/Scripts/vendor/bootstrap.min.js"></script>
<script src="/Scripts/vendor/jquery-1.11.2.min.js"></script>
<script src="/Scripts/plugins.js"></script>
<script src="/Scripts/main.js"></script>
</body></html>
error 438
Here's the general logic of how to access the cells of an HTML table:
Sub test()
Dim sht As Worksheet
Dim doc As New HTMLDocument
Dim targetTable As HTMLTable
Set sht = ThisWorkbook.Worksheets("Sheet1")
doc.body.innerHTML = sht.Range("M1") 'I just stored the html code in cell M1 as a string for the sake of demonstration
Set targetTable = doc.getElementsByClassName("table")(0) 'Get the first element from a collection of elements whose class name is "table"
Debug.Print targetTable.Rows(0).Cells(0).innerText 'Get the first row from the collection of rows that belong to the table and the first cell from the collection of cells that belong to this row.
End Sub
The code above will print Job # in the immediate window. This is the inner text of the first cell of the first row (which is the header of the first column). You can get the rest of the values accordingly.
Things to remember:
doc.getElementsByClassName("table") is a collection of elements whose class name is "table"
Same applies to .getElementsByTagName etc.
The first item in the collection has an index of 0
You can loop through all the elements in a collection using a For-Each
This .getelementClassName is wrong
This doc.getElementsByClassName("table")(0).getElementsByTagName("td")(0).innerText is correct
You can access an item in the collection either like that doc.getElementsByClassName("Something").Item(0) or like that doc.getElementsByClassName("Something")(0)
The error:
The method is
getElementsByClassName
or
getElementsByTagName
These return collections which you then index into e.g.
ie.document.getElementsByClassName("className")(0) 'first element
Making those changes should handle your initial error.
Targeting specific row and column:
You can use nth-of-type if automating with IE i.e. tr:nth-of-type(rowNumberHere) , td:nth-of-type(columnNumberHere).
I think you are after the second row first column so I would use css selectors
ie.document.querySelector(".table tr:nth-of-type(2) td:nth-of-type(1)").innerText
Modern browsers are optimized for css selectors so this should be an efficient method.
Entire table:
An easy way to copy an entire table is to use the clipboard
Option Explicit
Public Sub GetInfo()
Dim ie As New InternetExplorer, url As String, ws As Worksheet
Dim t As Date, clipboard As Object, hTable As Object
url = "url"
Const MAX_WAIT_SEC As Long = 10
Set ws = ThisWorkbook.Worksheets("Sheet1")
Set clipboard = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
With ie
.Visible = True
.Navigate2 url
While .Busy Or .readyState < 4: DoEvents: Wend
With .document
t = Timer
Do
On Error Resume Next
Set hTable = .querySelector(".table")
On Error GoTo 0
If Timer - t > MAX_WAIT_SEC Then Exit Do
Loop While hTable Is Nothing
End With
If hTable Is Nothing Then Exit Sub
clipboard.SetText hTable.outerHTML
clipboard.PutInClipboard
ws.Range("A1").PasteSpecial
.Quit
End With
End Sub
Looping rows and columns of a table:
If you want to loop rows and columns of a table and write out, see here.

Unable to click or select checkbox using selenium python webdriver chrome

After all unsuccessful tries I had to ask for the help.
The thing is I want to make script which will automatically login, go to specific tab ("WAN"), click appropriate check box (to disable NAT) and log out. (It's actually Huawei GPON router HG8245)..
My code goes fine until the check box, so...
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
driver=webdriver.Chrome(r"C:\chromedriver.exe") #load the driver => OK
driver.get("http://192.168.100.1") #go to this web page => OK
driver.find_element_by_id("txt_Username").send_keys("root") #username=root => OK
driver.find_element_by_id("txt_Password").send_keys("root") #password=root => OK
driver.find_element_by_xpath(".//*[#id='button']").click() #click Submit button => OK
driver.find_element_by_xpath(".//*[#id='headerTab']/ul/li[2]/div[2]").click() #Go to the 'WAN' tab => OK
And for the clicking of check box my tries:
#1
driver.find_element_by_xpath("//input[#value='InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1']").click() #=> NOT OK
#2
driver.find_element_by_xpath("//*[#id='record_1']/td[1]/input").click() #=> NOT OK
#3
driver.find_element_by_css_selector("#record_1 > td > input[name=\"rml\"]").click() #=> NOT OK
Of course all xpaths are checked in chrome via console (in the Mozilla as well) and they seems fine!
Any ideas how to solve this?
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<body>[![enter image description here][1]][1]
<div id="main">
<div id="header">
<div id="center" style="height: 495px;">
<div id="nav" style="height: 495px;">
<div id="content" style="height: 495px;">
<div id="topNav">
<div id="frameWarpContent" style="height: 470px;">
<iframe id="frameContent" marginheight="0" marginwidth="0" scrolling="no" src="html/network/wan.asp" style="height: 470px;" height="100%" frameborder="0" width="100%">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="Page" xmlns="http://www.w3.org/1999/xhtml" dir="ltl">
<head>
<body class="mainbody">
<script language="JavaScript" src="../../resource/common/util.js?1103405">
<script language="JavaScript" src="../../resource/english/jsdiff.js?1103405">
<script language="JavaScript" src="../../resource/common/tabdes.js?1103405">
<script language="javascript" src="../common/manage_mode.asp">
<script language="javascript" src="../common/user_info.asp">
<script language="javascript" src="../common/topo_info.asp">
<script language="javascript" src="../common/feature_info.asp">
<script language="javascript" src="../common/wan_prefix_acquire.asp">
<script language="javascript" src="../common/wan_address_acquire.asp">
<script language="javascript" src="../common/wan_dns.asp">
<script language="javascript" src="../common/wan_list.asp">
<script language="javascript" src="../common/wlan_list.asp">
<script language="javascript" src="../common/lanmode_list.asp">
<script language="javascript" src="../common/policyroute_list.asp">
<script language="javascript" src="wan_language.html?1103405">
<script language="javascript" src="../common/wan_pageparse.html?1103405">
<script language="javascript" src="../common/wan_databind.html?1103405">
<script language="javascript" src="../common/wan_control.html?1103405">
<script language="javascript" src="../common/wan_check.html?1103405">
<script language="JavaScript" src="../../resource/english/bbspdes.html?1103405">
<script>
<div id="PromptPanel">
<script>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<tr>
<td id="Wan Connection">
<table id="wanInstTable" class="tabal_bg" width="100%" cellspacing="1">
<tbody>
<tr class="tabal_title">
<tr id="record_0" class="tabal_01" onclick="selectLine(this.id);">
<tr id="record_1" class="tabal_01" onclick="selectLine(this.id);">
<td align="center">
<input name="rml" value="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1" onclick="" type="checkbox">
</td>
<td align="center">
<td align="center">
<td title="RealName :HSI Status :Connected IPAddress :10.10.10.10" align="center">
</tr>
</tbody>
</table>
<script>
<form id="ConfigForm">
</td>
</tr>
</tbody>
</table>
</body>
</html>
</iframe>
</div>
</div>
</div>
<div id="footer">
<div id="fresh">
</div>
</body>
</html>
*Edit: Modifying code tags and IP values
Considering provided HTML code sample you need to switch to iframe before handling check-box:
driver.switch_to.frame("frameContent")
driver.find_element_by_xpath("//tr[#id='record_1']//input").click()

How to pull a text from a table but the table has the same name as other tables? VBA, excel

I've made a code that would go to a website and pull their investment criteria. But I only need one cell in that table and the table class name is the same for multiple tables.
I need to get the EBITDA, which is on the table class = cTblListBody
Here's my code thus far:
Sub SearchBot()
Dim objIE As InternetExplorer
Dim aEle As HTMLLinkElement
Dim y As Integer
Dim result As String
Dim TR As Object, TD As Object
Dim tbl As Object, obj_tbl As Object
Set objIE = New InternetExplorer
objIE.Visible = True
objIE.navigate "https://website.com"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.document.getElementById("SearchTopBar").Value = _
Sheets("Sheet2").Range("A2").Value
Set oNode = objIE.document.getElementsByClassName("iPadHack tmbsearchright")
(0)
oNode.Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
b = 2
Dim tblEle
Set tblEle = objIE.document.getElementsByClassName("cTblListBody")(5)
Sheets("Sheet2").Range("B" & b).Value = tblEle.innerText
Debug.Print tblEle.innerText
b = b + 1
Next
objIE.Quit 'close the browser
End Sub
Full html code:
html
<head id="ctl02_headcontrol">
<body>
<div id="gcontainer" style="z-index:200000" onmouseout="calendarTimeout();"
onmouseover="if (timeoutId) clearTimeout(timeoutId);"></div>
<style>
<script type="text/javascript">
<img id="_jsVersionedShim" title=""
src="https://w3.ciqimg.com/CIQDOTNET/images/shim.gif?urwvid=3502569" alt=""
style="display:none;">
<script type="text/javascript">
<link title="IQ" rel="search"
type="application/opensearchdescription+xml"
href="/ciqdotnet/search/autocompleteprovidergenerator.axd">
<link rel="stylesheet" type="text/css"
href="/CIQDOTNET/library/Combined/CIQHeader.css">
<style>
<div id="topBanner" style="width: 100%; height: 69px;">
<table style="height: 100%" width="100%" cellspacing="0" cellpadding="0"
border="0">
<tbody>
<tr valign="bottom">
<tr id="bodyrow" style="height:100%;" valign="top">
<td id="ll_leftBorder_mid">
<td id="ll_cont" class="ll_cont_ex">
<td id="leftPageBorder" style="width: 10px;">
<td style="width: 100%;">
<div id="contentArea">
<script type="text/javascript">
<script type="text/javascript">
<div id="UpdateProgressDiv" style="visibility:hidden;"></div>
<script type="text/javascript"
src="/CIQDotNet/Charting/Library/highstock.js">
<script type="text/javascript"
src="/CIQDotNet/CreditAnalytics/CIQCharts/themes/light.js">
<script type="text/javascript"
src="/CIQDotNet/CreditAnalytics/CIQCharts/lib/util.js">
<script type="text/javascript"
src="/CIQDotNet/CreditAnalytics/CIQCharts/CIQCharts.js">
<style type="text/css">
<script type="text/javascript"
src="/CIQDotNet/News/library/NewsAndBlogs.js">
<script type="text/javascript">
<form id="frmMain" method="post" action="./company.aspx?companyId=30995038">
<div class="aspNetHidden">
<script type="text/javascript">
<script src="/CIQDotNet/WebResource.axd?d=nZzj3YZngGCPUXbcooPdPCjPJSuAIp
DU_l-5lPsFAlauINflCZuBPW8NfeQFL1nsY13w4LY1&t=635802961220000000"
type="text/javascript">
<script language="javascript">
<script src="/CIQDotNet/LeftLinks/LeftLinksContent.aspx
leftLinksHashKey=e1HX3w3nPsHpyHn6IEXdcA%3d%3d&urwvid=3502569"
type="text/javascript">
<script type="text/javascript">
<script src="/CIQDotNet/library/CIQDotNet/Web/functional.js"
type="text/javascript">
<script type="text/javascript">
<script src="/CIQDotNet/ScriptResource.axd
d=BQRO1XhoYSDCQiunG6j3W6BEdFJUaLhgrsqvXzeFZkJH6K5tgvKMDrgFuDHlO
1ymPMZRaduCK4dNstqE6toFrC4k8xUF9d5645" type="text/javascript">
<script src="/CIQDotNet/ScriptResource.axd?
<script src="Company/BubbleChart.asmx/js" type="text/javascript">
<script type="text/javascript">
<script src="/CIQDotNet/Research/Services/ResearchService.asmx/js"
type="text/javascript">
<div class="aspNetHidden">
<script type="text/javascript">
<div id="CompanyHeaderInfo" class="cPageTitle" style="margin-bottom:38px;">
<table class="cTblListBody" style="width:100%;" border="1">
<div style="width:100%;">
<div style="width:100%;">
<div style="width:100%;">
<div style="width:100%;">
<br class="tableSpacer">
<table style="width:100%;border-collapse:collapse;" cellspacing="0"
cellpadding="0">
<tbody>
<tr>
<td>
<table class="cTblHeaderBG" style="width:100%;">
<table class="cTblListBody" style="width:100%;border-collapse:collapse;"
cellspacing="0" cellpadding="2">
<a name="#ctl22$ctl09"></a>
<table class="cTblListBody" rules="all" cellspacing="1" cellpadding="2"
bordercolor="#d8dde1" border="1">
<tbody>
<tr class="cColHeaderBG">
<tr>
<tr style="background-color:#F9F9F9;">
<tr>
<tr style="background-color:#F9F9F9;">
<td>EBITDA</td>
<td style="width:50px;" align="right">
<span></span>
-
</td>
<td style="width:50px;" align="right">
<td style="width:50px;" align="right">
<td style="width:50px;" align="right">
</tr>
<tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div style="width:100%;">
<div style="width:100%;">
<div style="width:100%;">
<div style="width:100%;">
<br class="tableSpacer">
<div> </div>
<script type="text/javascript">
<script type="text/javascript">
<script language="JavaScript">
<script language="JavaScript">
<script language="JavaScript">
<script type="text/javascript">
</form>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
</div>
</td>
<td id="rightPageBorder" style="width: 10px;">
</tr>
<tr valign="top">
</tbody>
</table>
<div id="btmFooter" class="ftrBG">
<a id="_hotkey1" accesskey="1" tabindex="-1" onclick="HotKey(1);"
onfocus="HotKeyIE(1)" href="javascript:void(0);"
style="position:fixed;top:0;left:0"></a>
<a id="_hotkey2" accesskey="2" tabindex="-1" onclick="HotKey(2);"
onfocus="HotKeyIE(2)" href="javascript:void(0);"
style="position:fixed;top:1;left:0"></a>
<a id="_hotkey3" accesskey="3" tabindex="-1" onclick="HotKey(3);"
onfocus="HotKeyIE(3)" href="javascript:void(0);"
style="position:fixed;top:2;left:0"></a>
<a id="_hotkey4" accesskey="4" tabindex="-1" onclick="HotKey(4);"
onfocus="HotKeyIE(4)" href="javascript:void(0);"\
style="position:fixed;top:3;left:0"></a>
<a id="_hotkey5" accesskey="5" tabindex="-1" onclick="HotKey(5);"
onfocus="HotKeyIE(5)" href="javascript:void(0);"
style="position:fixed;top:4;left:0"></a>
<a id="_hotkey6" accesskey="6" tabindex="-1" onclick="HotKey(6);"
onfocus="HotKeyIE(6)" href="javascript:void(0);"
style="position:fixed;top:5;left:0"></a>
<a id="_hotkey7" accesskey="7" tabindex="-1" onclick="HotKey(7);"
onfocus="HotKeyIE(7)" href="javascript:void(0);"
style="position:fixed;top:6;left:0"></a>
<a id="_hotkey8" accesskey="8" tabindex="-1" onclick="HotKey(8);"
onfocus="HotKeyIE(8)" href="javascript:void(0);"
style="position:fixed;top:7;left:0"></a>
<a id="_hotkey9" accesskey="9" tabindex="-1" onclick="HotKey(9);"
onfocus="HotKeyIE(9)" href="javascript:void(0);"
style="position:fixed;top:8;left:0"></a>
<a id="_hotkey0" accesskey="0" tabindex="-1" onclick="HotKey(0);"
onfocus="HotKeyIE(0)" href="javascript:void(0);"
style="position:fixed;top:9;left:0"></a>
</body>
</html>
You need to get the third instance of that ClassName, so, instead of looping the collection of matching ClassName elements, try this:
Dim tblEle
Set tblEle = objIE.document.getElementsByClassName("cTblListBody")(2)
Then, I think you can you get the cell value from that element.
Also note:
You use variable i but I don't see that declared anywhere in code: For Each aEle In objIE.document.getElementsByClassName("cTblListBody").Rows.
(i).Cells(1).innerText. Should this be b instead of i?

Nested Layouts MVC5

I am new to MVC so pardon if my questions come across as stupid.
I have a main layout file (_MainLayout.cshtml) and a secondary layout file (_AdminLayout.cshtml). Both these files reside in my /Views/Shared folder.
The _MainLayout.cshtml looks like:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" type="image/x-icon" href="~/icons/favicon.ico" />
<title>U - #ViewData["Title"]</title>
<link rel="stylesheet" href="~/Content/Site.css"/>
</head>
<body>
<nav>
<div id="MainMenu" style="top:45px; height:40px; width:100%; position:fixed">
<ul style="list-style-type:none; text-align:center">
<li class="u-li-rightfloatinglink">#Html.ActionLink("Admin", "_AdminLayout", "Admin")</li>
<li class="u-li-rightfloatinglink">#Html.ActionLink("Contact", "Contact", "Home")</li>
<li class="u-li-rightfloatinglink">#Html.ActionLink("About", "About", "Home")</li>
<li class="u-li-rightfloatinglink">#Html.ActionLink("Home", "Index", "Home")</li>
</ul>
</div>
</nav>
<div id="MainBody" style="top: 80px; width:100%; text-align:center; position:fixed">
#RenderBody()
</div>
<div id="MainFooter" style="position:fixed; bottom:0px; width:100%; height:20px; background:#015da0">
<p style="display:table-cell; color:#ffffff; text-align:center; vertical-align: middle">© #DateTime.Now.Year - U</p>
</div>
#RenderSection("scripts", required: false)
</body>
The _AdminLayout.cshtml looks like:
#{
ViewBag.Title = "_AdminLayout";
Layout = "~/Views/Shared/_MainLayout.cshtml";
}
<h2>_AdminLayout</h2>
<div>
#RenderBody()
</div>
The ManageTableContent.cshtml is again supposed to be displayed in the #RenderBody section of the _AdminLayout.cshtml.
ManageTableContent.cshtml looks like:
#{
Layout = "~/Views/Shared/_AdminLayout.cshtml";
ViewBag.Title = "Manage Table Content";
}
<body>
<div class="u-div-header">
<p class="u-p-header">Manage Table Content</p>
</div>
<br />
<div style="width: 100%">
<table class="u-table-layouttable">
<tr>
<td class="u-td-description">Table Name here</td>
<td class="u-td-buttons">
<button class="u-button-addrecord" title="Add Record">
<img />
</button>
<button class="u-button-deleterecord" title="Delete Record">
<img />
</button>
<button class="u-button-clonerecord" title="Clone Record">
<img />
</button>
</tr>
<tr>
<td colspan="2">
<table id="ManagedTable" class="u-table-datatable">
<tr class="u-tr-datatable">
<td></td>
</tr>
</table>
</td>
</tr>
</table>
<table style="width: 100%">
<tr>
<td>
<input id="Submit" type="submit" value="Submit" style="float: right" />
<input id="Cancel" type="reset" value="Cancel" style="float: right" />
</td>
</tr>
</table>
</div>
</body>
For some reason if I get this error when I try and open my _AdminLayout.cshtml by selecting the Admin link from my _MainLayout.cshtml:
Additional information: The file "~/Views/Shared/_AdminLayout.cshtml" cannot be requested directly because it calls the "RenderBody" method.
Controller Code:
namespace U.Controllers
{
public class AdminController : Controller
{
// GET: Admin
public ActionResult ManageTableContent()
{
return View();
}
public ActionResult _AdminLayout()
{
ViewBag.Message = "Your admin page.";
return View();
}
}
}
If I remove the #RenderBody()from my code then the _AdminLayout.cshtml loads fine.
I need the #RenderBody() in my _AdminLayout.cshtml because here I will display partial Views again.
Any help would be appreciated.
You can only have one #RenderBody() per master layout (that's where the output of a View goes to).
If _AdminLayout.cshtml is not a master layout, then you should use #RenderPartial to insert partial views there.
Based on your comment,
when you call _AdminLayout action
then it calls automatically _AdminLayout.cshtml and as it has #RenderBody() method in his view file it get error. Action controller view can not hold #RenderBody().
you can do that way. Change your ActionResult _AdminLayout name to AdminLayout.
And create another view file named AdminLayout.cshtml.
And in that cshtml you can code this way.
#{
Layout = "~/Views/Shared/_AdminLayout.cshtml";
ViewBag.Title = "Manage Table Content";
}
I hope you understand why do you get this error.

Resources