I'm trying to upload a file in a nightwatch test that is being run on Browserstack in IE11. Here is what I have:
browser.execute(function (data) {
const el = document.querySelector('input#fileUpload');
el.style.display = "block";
el.removeAttribute('multiple');
}, []);
browser.setValue('input#fileUpload', require('path').resolve(__dirname + '/upload-files/test-doc.pdf'))
The error is a file not found issue, it works fine when being run on Chrome locally. Searching around, it seems like I need to upload the file to BS first, I found this gist and this PR but neither worked for me.
Since the file is not present on the machine of BrowserStack you might be encountering this error. You will need to use the 'setFileDetector' method provided by Selenium to upload a local file to remote grid. More details can be found on their documentation here - https://www.browserstack.com/automate/node#enhancements-uploads-downloads
Related
I am writing automation using Nightwatch node js. I have a test for uploading a file in my application and testing it locally works perfectly. However, when I test it using BrowserStack, BrowserStack cannot access the file in my local machine.
I have also tried setting FileDetector but it gives error saying setFileDetector is not a function on browser object.
I know this function is available for selenium driver object but I am javascript browser object for writing test scripts.
browser.setFileDetector(new remote.FileDetector());
I see that you want to perform the File Upload Operation for a file available on your local machine. You can review the link: https://www.browserstack.com/automate/node#enhancements-uploads-downloads for more details.
So I'm working on a Minecraft launcher (because why not, good experience), and I'm stuck when it comes to downloading the libraries.
I have a valid jar URL here. When you download it in the browser, it works fine. But, when you download it with Node.js, 7-zip gives this error when trying to open it:
An attempt was made to move the file pointer before the beginning of the file.
I'm using a module called snekfetch, but I've also tried it with request. Both items gave the same issue. Here's my current test code:
request.get('https://libraries.minecraft.net/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar').then(r => {
fs.writeFileSync('./mything.jar', r.body);
});
Am I doing something wrong to download the jar file?
Okay, so now that I've seen this answer, I need to modify the question. I've gotten it to work using pipes, but I need inline-code because this is a for loop that's downloading (hence my usage of writeFileSync, and in my actual code I use await for the request). Is it even possible to download and write without piping?
It turns out this is an issue with the snekfetch library. Switching to snekfetch v3 fixed it.
You can check out the status of the issue here.
I am deploying a meteor application to a digital ocean droplet with meteor upload. Everything goes well, the application gets deployed, database works, seeding of data works etc. But there is one problem i can't seem to be able to solve.
I use the meteor-uploads package (https://github.com/tomitrescak/meteor-uploads) for file uploads. Locally everything goes well, the file gets uploaded, finished callback gets called etc. But once I have deployed the application to the server it keeps giving me on of these errors, :
POST http://*ip*/upload net::ERR_CONNECTION_REFUSED
POST http://*ip*/upload net::ERR_EMPTY_RESPONSE
POST http://*ip*/upload net::ERR_CONNECTION_RESET
Any ideas are welcome, I have searched all over for a solution but none seems to fit my problem. I also installed to a fresh droplet but that didn't help. In none of my browsers (Mac Chrome, safari & firefox) does it work, on my phone (Android 5.0) I get the same errors. I am using the newest Meteor version 1.1.0.1
On local host you don't need to set the environmental variables, but the host services provides you should.
Check this tutorial to see how to put the environment variables.
Because the file-upload needs a startup-server-configuration, like this.
//file:/server/init.js
Meteor.startup(function () {
UploadServer.init({
tmpDir: process.env.PWD + '/.uploads/tmp',
uploadDir: process.env.PWD + '/.uploads/',
checkCreateDirectories: true //create the directories for you
})
});
But im not sure if putting this on a startup will work on digital ocean, like i say you you enter it, run printing and check if the /.uploads/ exists
I have a test for uploading a file (code below) in my application and testing it locally works perfectly. However, when I test it using BrowserStack, BrowserStack cannot access the file in my local machine.
I have checked their documentation about using BrowserStack with Node.js but I haven't seen any documentation about upload functionality. My question is, how do I tell BrowserStack to access my local file?
Has anyone encountered the same issue before?
this.selectJmxFile = function(jmxFilePath, done){
this.driver.findElement(webdriver.By.xpath("//input[#type='file']")).sendKeys(jmxFilePath);
this.driver.wait(function () {
return driver.isElementPresent(webdriver.By.css('.test.files.msg.right'));
}, this.timeout).then(function () {
driver.findElement(webdriver.By.css('.test.files.msg.right')).getText().then(function(text) {
expect(text).to.equal('1 new file(s) selected');
done();
});
});
};
where jmxFilePath is set as:
this.jmxFile = process.cwd() + '/test/functional/features/data/test.jmx';
Thanks!
Ok as it turns out this isn't supported yet as this has only been added in selenium v2.45.0 in Node.js. BrowserStack will have this functionality once they support the latest version of selenium. Guess I have to find another workaround!
You need to set the file detector and it would be transported to remote Browser Stack machine on which test is running -
webDriver.setFileDetector(new LocalFileDetector());
I have created a file upload system which allows the user to
upload .txt,.xls and .csv formats.When I executed in windows it is
running fine but now when I deployed the application in linux(Debian)
using tomcat server I am facing this issue:
The onsubmit method is called for all the file formats.
onSubmitComplete method is called only when text files are uploaded.I
want to use onSubmitComplete event as I am using progress bar and
wanted to perform necessary action on this event.
Here is my code:
file = new FileUpload();
form = new FormPanel();
file.setName("file");
file.setTitle("select a file");
submit = new Button("Upload");
submit.setTitle("upload file");
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
submit.addClickHandler(this);
form.addSubmitHandler(this);
form.addSubmitCompleteHandler(this);
}
Please tell me why the same code is working fine in windows and not in
linux.
It was resolved as it was not platform dependency it was browser dependency.I now installed google chrome and now it is running fine in linux.