/
tc_12.2.3.js
executable file
·78 lines (65 loc) · 2.74 KB
/
tc_12.2.3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
Author: Prateek
Description: This is a casperjs automated test script for showing that,After a file is uploaded to a notebook, it will be present in the Assets div
*/
//Begin Tests
casper.test.begin("Upload file will be visible in assets div", 4, function suite(test) {
var x = require('casper').selectXPath;
var github_username = casper.cli.options.username;
var github_password = casper.cli.options.password;
var rcloud_url = casper.cli.options.url;
var functions = require(fs.absolute('basicfunctions'));
var fileName = 'SampleFiles/PHONE.csv'; // File path directory
var system = require('system')
var currentFile = require('system').args[4];
var curFilePath = fs.absolute(currentFile);
var curFilePath = curFilePath.replace(currentFile, '');
fileName = curFilePath + fileName;
casper.start(rcloud_url, function () {
functions.inject_jquery(casper);
});
casper.wait(10000);
casper.viewport(1024, 768).then(function () {
functions.login(casper, github_username, github_password, rcloud_url);
});
casper.viewport(1024, 768).then(function () {
this.wait(9000);
console.log("validating that the Main page has got loaded properly by detecting if some of its elements are visible. Here we are checking for Shareable Link and Logout options");
functions.validation(casper);
});
functions.create_notebook(casper);
//Verifying whether file upload div is open or not
casper.wait(2000).then(function () {
if (this.visible(x(".//*[@id='file']"))) {
this.echo('File Upload pane div is open');
this.wait(5000);
}
else {
this.echo('File upload div is not open,hence opening it');
this.wait(6000);
this.click(x(".//*[@id='accordion-right']/div[2]/div[1]"));
this.wait(5000);
}
});
casper.wait(2000).then(function () {
casper.page.uploadFile("#file", fileName);
console.log('Selecting a file');
});
casper.wait(2000).then(function () {
this.wait(5000, function () {
this.click(x(".//*[@id='upload-to-notebook']"));
console.log("Clicking on Upload to notebook check box");
this.click(x(".//*[@id='upload-submit']"));
console.log("Clicking on Submit icon");
});
});
casper.wait(10000).then(function () {
this.waitUntilVisible(x('//*[contains(text(), "added")]'), function then() {
console.log("File has been uploaded");
});
this.test.assertSelectorHasText(x(".//*[@id='asset-list']/li[3]/a/span[1]"), 'PHONE.csv', 'Uploaded file is present in assets div');
});
casper.run(function () {
test.done();
});
});