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

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:

Related

value is not pass to partials files express handlebars cant find the error

I am asking this question again because i did not get any response on my previous question. i am trying to fetch the pages names from DB to sidebar but i can't. my sidebar in the partials folder.
what i have tried
// controller
index: (req, res) => {
db.query("SELECT * FROM mp_pages", function (err, pages) {
return res.render('layouts/admin', { page: pages });
})
},
// here is the admin layout
{{> header }}
<body id="page-top">
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
{{#each pages}}
{{> adminSidebar this}}
{{/each}}
{{!-- {{> adminSidebar pages}} --}}
<!-- Cotent Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
{{> topbar}}
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
{{{ body }}}
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<!-- Footer -->
{{> footer }}
and this is my exact sidebar where i want to show the page title.
<!-- Nav Item - Dashboard -->
<li class="nav-item">
<a class="nav-link" href="index.html">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>{{this}}</span></a>
</li>
<!-- End of Sidebar -->
what is the exact way pass the data from controller to partials ?
{{> header }}
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
{{> adminSidebar pages=pages}}
{{!-- {{> adminSidebar pages}} --}}
<!-- Cotent Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
{{> topbar}}
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
{{{ body }}}
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<!-- Footer -->
{{> footer }}
<!-- Nav Item - Dashboard -->
<li class="nav-item">
{{#each pages}}
<a class="nav-link" href="index.html">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>{{this}}</span>
</a>
{{/each}}
</li>
<!-- End of Sidebar -->

VBA Excel - Filling in webforms unable to click submit button

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"

Material design flex not working in browsers other than chrome

i am new to angular material design, my code of angular material design is working fine in google chrome but not currently working with Mozilla Firefox and Internet explorer. I know there is some error in my code while defining layout or flex. So i want to know what wrong i have written
<html lang="en" >
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<script type="text/javascript">
angular.module('firstApplication', ['ngMaterial'])
.config(function($mdThemingProvider) {
$mdThemingProvider.theme('default')
.primaryPalette('light-green')
.accentPalette('red')
.warnPalette('green');
});
</script>
<style type="text/css">
.md-toolbar.md-default-theme:not(.md-menu-toolbar).md-warn, md-toolbar:not(.md-menu-toolbar).md-warn{
color: white;
}
</style>
</head>
<body ng-app="firstApplication" ng-cloak>
<md-toolbar class="md-primary md-hue-5">
<div class="md-toolbar-tools">
<h2 class="md-flex">My App</h2>
</div>
</md-toolbar>
<md-content class="md-padding">
<div layout="row" layout-align="center stretch">
<div layout="column" flex-sm="80" layout-align="center stretch" flex flex-gt-xs="40">
<md-card flex="60" class="md-padding" >
<div layout="column" layout-align="center center">
<img src="https://material.angularjs.org/1.0.1/img/icons/angular-logo.svg" flex >
<h4>Login to your account</h4>
</div>
<md-card-content>
<md-input-container class="md-icon-float md-block">
<!-- Use floating label instead of placeholder -->
<label>Username</label>
<md-icon class="name">
<i class="material-icons ">perm_identity</i>
</md-icon>
<input ng-model="user.name" type="text">
</md-input-container>
<md-input-container class="md-icon-float md-block">
<!-- Use floating label instead of placeholder -->
<label>Password</label>
<md-icon class="name">
<i class="material-icons">lock</i>
</md-icon>
<input ng-model="user.name" type="password">
</md-input-container>
<div layout="row" layout-xs="column">
<md-checkbox class="md-primary" flex-gt-xs="70" md-no-ink>
<span style="line-height:32px;">
Remember Me
</span>
</md-checkbox>
Forgot Password?
</div>
<div layout="row" layout-align="center center">
<md-button class="md-primary md-raised" flex="50"> Login </md-button>
</div>
</md-card-content>
</md-card>
</div>
</div>
</md-content>
</body>
</html>

Watir-Webdriver Can't access a element with id and class

I am having a trouble trying to access a nested div that has id and class, I don't know why but I only can see his parent.
This is the HTML code:
<html xml: lang="en" xmlns="http://www.w3.org/1999/xhtml" webdriver="true">
<head id="ctl00_Head1"></head>
<body onunload="deshabilitaHistoria();" onload="deshabilitaHistoria();">
<form id="aspnetForm" action="ConsultaReceptor.aspx" method="post">
<div class="aspNetHidden"></div>
<script type="text/javascript">
//<![CDATA[ var theForm = document.forms['aspnetF…
</script>
<script type="text/javascript" src="/WebResource.axd?d=w3hP2KgSK0z5QKKeYrfjOjGIUO1WTymINPb1PJaT2…AjAREgWLQ_9gOp19BJLQL03iwEhxTK_VlYMMLk1&t=635757173565717094"></script>
<script type="text/javascript" src="/ScriptResource.axd?d=JZxa8gqDBBrScXZMeyf5kBYrESwOlB3UypK5wa…sdGfW92qpYAba8RsL1xfZ_4qsx20HZ3gnR8gWNG81&t=ffffffff805766b3"></script>
<script type="text/javascript" src="/ScriptResource.axd?d=Z6KcuJ_OzxT6nvHmSunXcYkoXPPYk2iZ6iqqza…Mhq8K8bd09EWTYt8d-AfoMh3rrp75DWb5vMAI1wb0&t=ffffffff805766b3"></script>
<script type="text/javascript">
//<![CDATA[ var PageMethods = function() { PageMe…
</script>
<div class="aspNetHidden"></div>
<script type="text/javascript">
//<![CDATA[ Sys.WebForms.PageRequestManager._init…
</script>
<div id="cuerpo_principal">
<div id="encabezado"></div>
<div id="menucontainer"></div>
<div id="cuerpo" style="margin-top: 30px">
<h2 class="subtitle">
Consultar Facturas Recibidas
</h2>
<span></span>
<br></br>
<br></br>
<div id="ctl00_MainContent_PnlConsulta" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl00_MainContent_BtnBusqueda')">
<div id="ctl00_MainContent_UpnlBusqueda"></div>
<div id="ctl00_MainContent_UpnlResultados">
<div id="ctl00_MainContent_PnlResultados" class="pnlResultados" style="height:auto;display:inline;">
<div id="DivContenedor" class="resultados" style="width: 900px; margin-left: 40px; overflow-x: scroll; height: auto; float: left">
<div id="ContenedorDinamico" style="margin-left: 0px;">
<table class="encabezadoresultado"></table>
<div id="DivPaginas" style="height: auto;">
<div id="masivapg0" class="pgActual"></div>
The div that i am trying to access is
div id="masivapg0" class="pgActual"
I am trying to access the element by the following code, however i always get a false result:
print browser.form(id: 'aspnetForm').div(id: 'cuerpo_principal').div(id: 'cuerpo').div(id: 'ctl00_MainContent_PnlConsulta').div(id: 'ctl00_MainContent_UpnlResultados').div(id: 'ctl00_MainContent_PnlResultados').div(id: 'DivContenedor').div(id: 'ContenedorDinamico').div(id: 'DivPaginas').div(id: 'masivapg0').exist?
But if i search for his parent i always get a true response:
print browser.form(id: 'aspnetForm').div(id: 'cuerpo_principal').div(id: 'cuerpo').div(id: 'ctl00_MainContent_PnlConsulta').div(id: 'ctl00_MainContent_UpnlResultados').div(id: 'ctl00_MainContent_PnlResultados').div(id: 'DivContenedor').div(id: 'ContenedorDinamico').div(id: 'DivPaginas').exist?
Any idea of why could this be happening?
your help is appreciated!
I loaded your html into a file and ran it in watir and, while the browser didn't display anything likely due to the incomplete html code, it didn't have any problem returning true like so:
browser.div(:id => "masivapg0").exists?
#=> true
id tags are supposed to be unique, so you shouldn't have to provide any more selectors than this...

How to open Jquery UI dialog with image and text

I am novice in JQuery UI. I am trying code for opening jquery dialog with image and text from existing code in one of div tags. My code is
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script>
$(document).ready(function(){
$(".peter_pic").click(function(){
$( ".peter" ).dialog( "open" );
});
$( ".peter" ).dialog({ autoOpen: false });
});
$( window ).load(function() {
$(".peter").hide();
});
</script>
<div class="Table" style="display: table;" >
<div style="display: table-row;">
<div style="display: table-cell;" class = "test">
<img class = "peter_pic" src="someimage.jpg" />
<div data-role="popup" class="peter">
Display some text. Display some text. Display some text.
</div>
</div>
</div>
</div>
I figured out on my own about the solution.
I added multiple img tag. This solved the problem.
<div class="Table" style="display: table;" >
<div style="display: table-row;">
<div style="display: table-cell;" class = "test">
<img class = "peter_pic" src="someimage.jpg" />
<div data-role="popup" class="peter">
<img class = "peter_pic" src="someimage.jpg" />
Display some text. Display some text. Display some text.
</div>
</div>
</div>
</div>

Resources