I know that for web automation UiPath recommends using IE in most cases since UiPath can interact with it in a more “native” way using its browser COM Object. The other browsers will have limitations and might struggle in case of the version updates. However, in some situations, it is not possible to use IE, like in my work we have an agreement with Google for work and much of our internal sites do not work in IE.
To complete UiPath Level 3 Advanced Certification (online): Assignment 2 - Generate Yearly Report, you must create a robot to perform the following:
The problem is that UiExplorer cannot find the correct selector, which makes it difficult to get the text from the Google Chrome popup because it is not rendered in the same way as it is for IE and does not expose the text attribute (among other ones). Here is a snippet from the acme-test site for creating the alerts to help define the selector and here is a UiPath XAML file:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<html>
<head>
<title>Upload reports</title>
</head>
<body>
<!-- Page Content -->
<div class="container">
<button type="button" class="btn btn-primary" id="buttonUpload">Upload Report</button>
<script type="text/javascript">
jQuery(document).ready(function() {
$('input[type=file]').on('change', prepareUpload);
function prepareUpload(event) {
files = event.target.files;
$('#upload-file-info').html(files[0].name)
}
jQuery('#buttonUpload').click(function(event) {
event.stopPropagation(); // Stop stuff happening
event.preventDefault(); // Totally stop stuff happening
var vTaxID = jQuery('#vendorTaxID').val();
var rYear = jQuery('#reportYear').val();
// If nothing is filled
if (vTaxID == "" || rYear == "") {
alert('Plase fill in the Vendor TaxID and Report Year!');
return;
}
if (typeof files === 'undefined') {
alert('Please select the Report File');
return;
}
// Create a formdata object and add the files
var data = new FormData();
jQuery.each(files, function(key, value) {
data.append(key, value);
});
console.log('...');
jQuery.ajax({
url: "/cmajax.php?cmd=uploadReport&cvTaxID=" + vTaxID + "&crYear=" + rYear,
type: "POST",
data: data,
cache: false,
dataType: 'json',
processData: false, // Don't process the files
contentType: false, // Set content type to false as jQuery will tell the server its a query string request
})
.always(function(msg) {
console.log('done');
if (msg.responseText == 'bad')
alert("Some problems were encountered.");
else {
console.log(msg);
alert('Report was uploaded - confirmation id is ' + msg.responseText);
}
});
})
});
</script>
</div>
</body>
</html>