<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article How to implement the File Upload action on Browser clickpath monitor with help of JavaScript Event (Simple Method) in Troubleshooting</title>
    <link>https://community.dynatrace.com/t5/Troubleshooting/How-to-implement-the-File-Upload-action-on-Browser-clickpath/ta-p/209323</link>
    <description>&lt;H1&gt;Summary&lt;/H1&gt;
&lt;P&gt;Synthetic Browser Clickpath monitors don't support File Upload actions. However, we can perform the same action with a JavaScript Event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Resolution&lt;/H1&gt;
&lt;P&gt;The below JavaScript code snippet is a simple way to upload a file without capturing the File Upload HTTP request and response details.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;var cssselector = "input[type=file]"; //Replace with your file upload input selector
var data = "data&amp;amp;colon;text/plain;base64, RmlsZXVwbG9hZHRlc3Q="; //Convert your file into base64 format and assign it to the data variable. Make sure that file size should be minimum as we will be adding this code to our synthetic script.
var filename = "fileuploadtest.txt"; //Replace with the filename with the extension
const parts = data.split(';base64,');
const imageType = parts[0].split(':')[1];
const decodedData = window.atob(parts[1]);
const uInt8Array = new Uint8Array(decodedData.length);
for (let i = 0; i &amp;lt; decodedData.length; ++i) {
    uInt8Array[i] = decodedData.charCodeAt(i);
}
var blob = new Blob([uInt8Array], {
    type: imageType
});
var element = document.querySelector(cssselector);
var file = new File([blob], filename, {
    type: imageType
});
var container = new DataTransfer();
container.items.add(file);
element.files = container.files;
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", true, true);
element.dispatchEvent(evt);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;P&gt;Get the CSS selector for the file upload input element by right-clicking on the element and selecting Inspect. This will open Developer tools&lt;/P&gt;
&lt;DIV id="tinyMceEditorMareeswaran_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image1.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/11011iBBC9C9F28D57539F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image1.png" alt="image1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Right-click on the element in Developer tools and select Copy - &amp;gt; Copy Selector&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditorMareeswaran_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image2.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/11012i1EE89957CFAA7F6B/image-size/large?v=v2&amp;amp;px=999" role="button" title="image2.png" alt="image2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Replace the selector on the snippet code above&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Convert your file into base64 format and assign it to the data variable. Make sure that file size is minimized, as we will be adding this code to our synthetic script.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Assign this base64 output into the data variable&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Rename the filename which you want to modify with the extension&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Add this JavaScript code into the JavaScript Event of your Browser clickpath monitor&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditorMareeswaran_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image3.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/11013iDE6AF2D805838C96/image-size/large?v=v2&amp;amp;px=999" role="button" title="image3.png" alt="image3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;H1 id="toc-hId--522716467"&gt;&lt;SPAN&gt;What's next&lt;/SPAN&gt;&lt;/H1&gt;
&lt;DIV class="p-rich_text_section"&gt;If none of the previous steps resolved the issue,&lt;/DIV&gt;
&lt;UL class="p-rich_text_list p-rich_text_list__bullet p-rich_text_list--nested" data-stringify-type="unordered-list" data-list-tree="true" data-indent="0" data-border="0"&gt;
&lt;LI data-stringify-indent="0" data-stringify-border="0"&gt;Business Insights or ACE Services can script the monitor for you. Contact your Customer Success Manager or Account Executive. Or&lt;/LI&gt;
&lt;LI data-stringify-indent="0" data-stringify-border="0"&gt;Chat can provide direction on using the product, but don't create scripts. Open a chat, provide a link to the browser clickpath, and the error you're seeing&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;You can find further troubleshooting tips for Synthetic in the&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://community.dynatrace.com/t5/Troubleshooting/Synthetic-Troubleshooting-Map/ta-p/250426" target="_blank" rel="noopener"&gt;Synthetic Troubleshooting Map&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 15 May 2025 13:47:25 GMT</pubDate>
    <dc:creator>Mareeswaran</dc:creator>
    <dc:date>2025-05-15T13:47:25Z</dc:date>
    <item>
      <title>How to implement the File Upload action on Browser clickpath monitor with help of JavaScript Event (Simple Method)</title>
      <link>https://community.dynatrace.com/t5/Troubleshooting/How-to-implement-the-File-Upload-action-on-Browser-clickpath/ta-p/209323</link>
      <description>&lt;H1&gt;Summary&lt;/H1&gt;
&lt;P&gt;Synthetic Browser Clickpath monitors don't support File Upload actions. However, we can perform the same action with a JavaScript Event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Resolution&lt;/H1&gt;
&lt;P&gt;The below JavaScript code snippet is a simple way to upload a file without capturing the File Upload HTTP request and response details.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;var cssselector = "input[type=file]"; //Replace with your file upload input selector
var data = "data&amp;amp;colon;text/plain;base64, RmlsZXVwbG9hZHRlc3Q="; //Convert your file into base64 format and assign it to the data variable. Make sure that file size should be minimum as we will be adding this code to our synthetic script.
var filename = "fileuploadtest.txt"; //Replace with the filename with the extension
const parts = data.split(';base64,');
const imageType = parts[0].split(':')[1];
const decodedData = window.atob(parts[1]);
const uInt8Array = new Uint8Array(decodedData.length);
for (let i = 0; i &amp;lt; decodedData.length; ++i) {
    uInt8Array[i] = decodedData.charCodeAt(i);
}
var blob = new Blob([uInt8Array], {
    type: imageType
});
var element = document.querySelector(cssselector);
var file = new File([blob], filename, {
    type: imageType
});
var container = new DataTransfer();
container.items.add(file);
element.files = container.files;
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", true, true);
element.dispatchEvent(evt);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;P&gt;Get the CSS selector for the file upload input element by right-clicking on the element and selecting Inspect. This will open Developer tools&lt;/P&gt;
&lt;DIV id="tinyMceEditorMareeswaran_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image1.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/11011iBBC9C9F28D57539F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image1.png" alt="image1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Right-click on the element in Developer tools and select Copy - &amp;gt; Copy Selector&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditorMareeswaran_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image2.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/11012i1EE89957CFAA7F6B/image-size/large?v=v2&amp;amp;px=999" role="button" title="image2.png" alt="image2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Replace the selector on the snippet code above&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Convert your file into base64 format and assign it to the data variable. Make sure that file size is minimized, as we will be adding this code to our synthetic script.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Assign this base64 output into the data variable&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Rename the filename which you want to modify with the extension&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;Add this JavaScript code into the JavaScript Event of your Browser clickpath monitor&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditorMareeswaran_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image3.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/11013iDE6AF2D805838C96/image-size/large?v=v2&amp;amp;px=999" role="button" title="image3.png" alt="image3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;H1 id="toc-hId--522716467"&gt;&lt;SPAN&gt;What's next&lt;/SPAN&gt;&lt;/H1&gt;
&lt;DIV class="p-rich_text_section"&gt;If none of the previous steps resolved the issue,&lt;/DIV&gt;
&lt;UL class="p-rich_text_list p-rich_text_list__bullet p-rich_text_list--nested" data-stringify-type="unordered-list" data-list-tree="true" data-indent="0" data-border="0"&gt;
&lt;LI data-stringify-indent="0" data-stringify-border="0"&gt;Business Insights or ACE Services can script the monitor for you. Contact your Customer Success Manager or Account Executive. Or&lt;/LI&gt;
&lt;LI data-stringify-indent="0" data-stringify-border="0"&gt;Chat can provide direction on using the product, but don't create scripts. Open a chat, provide a link to the browser clickpath, and the error you're seeing&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;You can find further troubleshooting tips for Synthetic in the&amp;nbsp;&lt;/SPAN&gt;&lt;A class="" href="https://community.dynatrace.com/t5/Troubleshooting/Synthetic-Troubleshooting-Map/ta-p/250426" target="_blank" rel="noopener"&gt;Synthetic Troubleshooting Map&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 May 2025 13:47:25 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Troubleshooting/How-to-implement-the-File-Upload-action-on-Browser-clickpath/ta-p/209323</guid>
      <dc:creator>Mareeswaran</dc:creator>
      <dc:date>2025-05-15T13:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to implement the File Upload action on Browser click path monitor with help of JavaScript Event(Simple Method)</title>
      <link>https://community.dynatrace.com/t5/Troubleshooting/How-to-implement-the-File-Upload-action-on-Browser-clickpath/tac-p/212129#M214</link>
      <description>&lt;P&gt;Great Write up&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/40562"&gt;@Mareeswaran&lt;/a&gt;! thank you&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 19:28:21 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Troubleshooting/How-to-implement-the-File-Upload-action-on-Browser-clickpath/tac-p/212129#M214</guid>
      <dc:creator>ChadTurner</dc:creator>
      <dc:date>2023-05-12T19:28:21Z</dc:date>
    </item>
  </channel>
</rss>

