Not able to see file uploaded successfully

Hello team I am trying to write a synthetic script to upload a file. After clicking the browse button I need to upload the file from my local machine. I tried writing the below code snippet. But it Does not work. Can you please help me with this

var fs = require(‘fs’);
var crypto = require(‘crypto-js’);
.then(function(){
return new Promise(function(resolve, reject){
fs.writeFile(’/tmp/pic.jpg’, crypto.randomBytes(64).toString(‘hex’), function(err){
if (err) reject(err);
else resolve(“abcd”);
})
}).then(function(results){
return $browser.waitForAndFindElement({xpath:"//em//button[text()=‘Browse…’]"},50000).then(function(elem2){
$browser.sleep(10000)
elem2.sendKeys("/tmp/pic.jpg");
})
}).catch(function(err) {
console.log(“error here: " + err);
})
}).then(function(){
$browser.sleep(9000)
$browser.waitForAndFindElement($driver.By.xpath(”//em//button[text()=‘Upload’]"),60000).click();
})

Need to click on browse upload the document

Hi @ashna.gupta1 Can you share the permalink to your Synthetics monitor which has the above script? I’d like to understand the error it is throwing when using this script.