How to integrate Jquery with html

How to integrate Jquery with html

Hi All,

This is my first question on this forum.

I am automating a process wherein I need to login to a website and navigate to specific tab and then download few CSV files from that website.

I have written a Jquery code which works fine in chrome console but I want to integrate this code with html and I am not able to do that as I am not sure what should be called in body tag of html.

Can somebody please help me ?

  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4. <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  5. <script type="text/javascript"> 

  6. $(document).ready(function () {
  7.        $('.ibody tr').each(function (a, b) {
  8.   var count=0;
  9.       var name = $('.cl', b).text();
  10.       if(name.indexOf(".CSV")!==-1 && name.indexOf("TAS")!==-1){
  11.       var d= a-9;
  12.       var hiddenIFrameID = 'hiddenDownloader' + count++;
  13.       var element=document.createElement('a');
  14.      element.href = "https://www.shipper-ml.com/viewReports.do?ctrl=reportListForDownload&action=DownloadReport&param="+d;
  15. element.target='_blank';
  16. element.classList.add("download");
  17. document.body.append(element);

  18.           }
  19.             });
  20. setTimeout(function(){
  21. var linkslength=$(".download").length;
  22. for(var i=0;i<linkslength;i++)
  23. {
  24. $(".download")[i].click()}
  25. },500);
  26.         });
  27. </script>
  28.     </head>
  29.     <body>

  30.            <div class="container">
  31.     <div id="objectsDiv">
  32.     <div id="lc_ctrl1341970887">
  33.     <table class="ibody">
  34.      <tbody>
  35.                         <tr class="header">
  36.                             <td>
  37.                                 Report ID
  38.                             </td> 
  39.                             <td>
  40.                                Version No.
  41.                             </td>
  42.                             <td>
  43.                                 Report Type
  44.                             </td>
  45.                             <td>
  46.                                Date Created
  47.                             </td>
  48.                             <td>
  49.                                 Status
  50.                             </td>
  51. <td align="center">
  52. Excel
  53. </td>
  54. <td align="center">
  55. XML
  56. </td>
  57.                         </tr>
  58.                     </tbody>
  59.                 </table>
  60. </div>
  61.         </div>
  62.      </div>

  63. </body>
  64. </html> 
  65.     </body>
  66. </html>