mardi 23 août 2016

JS : Upload automatically a file to a form

I'm programing a bot which do some tests on the UI of an application developed with AngularJS. To do that, I use PhantomJS BUT, I'm blocked... In fact, I must upload a .csv file in order to validate the form, but I cannot for the moment. I have no idea how resolve this problem.

I have found this : page.uploadFile('input[name=image]', '/path/to/some/photo.jpg'); BUT, other problem... I use Mocha for testing and my tests are injected into the code of the app. So, i don't know how get the page object.

A simple plan of my architecture :

launcher.js

Initialize PhantomJS
page.open() {
    page.evaluate() {
        page.injectJs(all my tests);
    }
}

test_1.js

describe...
it('should works', ...) {
    Fill form 
}

Thank you !

Aucun commentaire:

Enregistrer un commentaire