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());
Related
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
I am trying to connect to a Realm instance from an aws lambda (node) with the following code:
await Realm.Sync.User.login('https://server.realm.io', 'username', 'password')
.then((user) => {
let config = user.createConfiguration();
config.schema = [Schema];
Realm.open(config).then((realm) => {
//Do some cool stuff });
The problem is it tries to create a directory realm-object-server when it logins. As we know the lambdas file system is read-only except for the tmp folder. Is there a way to tell realm to write this realm-object-server to the tmp folder or is there a way to login that doenst create a direcotry at all?
Thanks in advance for the help
I ran into the same issue using Realm from a Google Cloud Function. None of the Realm configuration options like path or inMemory seemed to have any effect. After much digging, the solution I found was to call process.chdir('/tmp') prior to opening the Realm. This changes the current NodeJS process's working directory as explained in the NodeJS documentation. This allowed me to open the realm successfully.
I am working with Electron and Node.js. We have developed an application that works fine on windows and as a requirement had to package it for mac os. I packaged the application using electron-packager, the packaging process completes and package is generated. Double clicking it throws an error that permission denied for mkdir, as i am using node localstorage to maintain some settings on the user's local machine. somehow mac doesn't local storage to create folder in the root of the application. Any help in this matter will be great. Thanks
First off, is the code in question in the main process or in a renderer process? If it is the latter, you don't need to use 'node-localstorage', because you can use the renderer's native LocalStorage. If you are in the main process, then you need to provide your own storage strategy so using 'node-localstorage' is a viable option.
In any case, you need to carefully consider where to store the data; for starters, let's look at where Electron's renderer processes would store its LocalStorage data: this differs based on the OS, but you can get and set the paths using the app module -- the path in question is userData, which on OS X would default to ~/Library/Application Support/<App Name>. Electron uses that folder to persist cookies, caches, LocalStorage etc. so I would suggest using that folder as well. (Otherwise, refer to XDG defaults for good defaults)
What your example above was trying to do is store your 'errorLogDb' in the current working directory, which might depend on your OS, where your App is installed, how you executed it, etc.
Finally, it's a good idea to differentiate between your 'production' app and your app during development and testing, because you might not want to use the same storage folders for every environment. In any case, just writing to './errorLogDb' is likely to cause lots of headaches so I'd be thankful for the permission denied error.
this strategy worked for me:
const { LocalStorage } = require('node-localstorage');
let ls;
mb.on('ready', () => {
let prefsPath = mb.app.getPath('userData') + '/prefs';
ls = new LocalStorage(prefsPath);
loadPrefs();
});
mb.on('after-create-window', () => { /* ls... */ }
exports.togglePref = () => { /* ls... */ }
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
Versions
I'm using Meteor 1.0.3 and node 0.10.35 on a small Ubuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-3d50120d EC2 instance.
Context
I know how to do server side debugging on my development box, just $ meteor debug and open another browser pointing to the url it produces -- works great.
But now, I'm getting a server error on my EC2 instance I'm not getting in development. So I'd like to set up a remote debug session sever side.
Also, I deployed to the EC2 instance using the Meteor-up package (mup).
EDIT
In an effort to provide more background (and context) around my issue I'm adding the following:
What I'm trying to do is, on my EC2 instance, create a new pdf in a location such as:
application-name/server/.files/user/user-name/pdf-file.pdf
On my OSX development box, the process works fine.
When I deploy to EC2, and try out this process, it doesn't work. The directory:
/user-name/
for the user is never created for some reason.
I'd like to debug in order to figure out why I can't create the directory.
The code to create the directory that works on my development box is like so:
server.js
Meteor.methods({
checkUserFileDir: function () {
var fs = Npm.require('fs');
var dir = process.env.PWD + '/server/.files/users/' + this.userId + '/';
try {
fs.mkdirSync(dir);
} catch (e) {
if (e.code != 'EEXIST') throw e;
}
}
});
I ssh'd into the EC2 instance to make sure the path
/server/.files/user/
exists, because this portion of the path is neccessary in order for the above code to work correctly. I checked the path after the code should have ran, and the
/user-name/
portion of the path is not being created.
Question
How can I debug remote server side code in a easy way on my EC2 instance, like I do on my local development box?
Kadira.io supports remote errors/exceptions tracking. It allows you to see the stacktrace on server side exceptions in the context of your meteor methods.
See https://kadira.io/error-tracking.html for more detail.
It seems in my case, since I'm using Meteor-up (mup), I can not debug per-say, but get access to the remote EC2 instance server console and errors by using command $ mup logs -f on my development box.
This effectively solves my issue with being blind on the server side remote instance.
It still falls short of actual debugging remotely, which speeds up the process of finding errors and performance bottlenecks, but it's all we have for now.
For someone who still searching:
#zodern added server-side debugging of meteor apps to great meteor-up tool:
https://github.com/zodern/meteor-up/pull/976
Do mup meteor debug in deployment dir and you will be almost set, just follow the text.