How to Import a file from the system, using CasperJS

28 views
Skip to first unread message

Prateek Naik

unread,
Jun 3, 2015, 5:30:21 AM6/3/15
to casp...@googlegroups.com
Hi, I am using Casper JS to automate the application and I am stuck in this situation, so please help me.

The testing scenario is, i need to import a file from my local system.
 below is the HTML code:

<div id="import-notebook-file-dialog" class="modal fade in" style="display: block;" aria-hidden="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" aria-hidden="true" data-dismiss="modal" type="button">×</button>
<h3>Import Notebook File</h3>
</div>
<div class="container">
<p>
<input id="notebook-file-upload" type="file" size="50"/>
</p>
<p>
<span style="display: inline;"/>
</p>
<p>
<span style="display: inline;">
Notebook description: 
<input class="form-control-ext" type="text" size="50"/>
</span>
</p>
</div>
<div class="modal-footer">
<span class="btn btn-cancel">Cancel</span>
<span class="btn btn-primary">Import</span>
</div>
</div>
</div>
</div>

and below is the CasperJS code which I am using
casper.then(function () {       
        this.click('#import_notebook_gist');
        this.echo('opened import notebook dialog box');
        this.wait(2000);
        this.page.uploadFile('#notebook-file-upload', '/home/prateek/Download/slow 15.gist');
        this.wait(2000);
        this.evaluate(function () {
            $('.btn.btn-primary').click();
            console.log("Clicking on import button");
        });
    });

Please help me...

Reply all
Reply to author
Forward
0 new messages