示例#1
0
casper.test.begin(" Checking line numbers in executing mode", 6, 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 temp;
    var notebook_id = "2c648b4f631d27da2859";
    
    casper.start(rcloud_url, function () {
        casper.page.injectJs('jquery-1.10.2.js');
    });
    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);
    });
    
    //open mark down notebook belonging to some different user
    casper.viewport(1366, 768).thenOpen('http://127.0.0.1:8080/main.html?notebook=' + notebook_id, function () {
        this.wait(10000);
        this.then(function () {
            title = functions.notebookname(casper);
            this.echo("Notebook title : " + title);
            this.wait(3000);
        });
    });
    
    functions.fork(casper);
    
	casper.then(function(){
		console.log('verifying line numbers are visible or not when the cell is in editable mode');
		var line_numbers = [];
		for(var i=1 ; i<=3 ; i++)
		{
		line_numbers [i-1] = this.fetchText({type: 'xpath', path: ".//*[@id='part1.R']/div[3]/div[1]/div[2]/div/div[1]/div[1]/div["+ i +"]"});
		}
		var z = line_numbers.length;
		if ( z == 3)
		{
			this.test.pass("line numbers in code block are visible in non editable mode");
		}
		else
		{
			this.test.fail("line numbers in code block are not visible in non editable mode");
		}
		
	});
	
	casper.run(function () {
        test.done();
    });
});
示例#2
0
文件: flush.js 项目: gatsbyjs/gatsby
module.exports = async () => {
  // Submit events on background w/o blocking the main process
  // nor relying on it's lifecycle
  const forked = fork(join(__dirname, `send.js`), {
    detached: true,
    stdio: `ignore`,
    execArgv: [],
  })
  forked.unref()
}
示例#3
0
casper.test.begin(" Name of Forked notebooks", 6, 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 temp ;
    var temp1 ;
    
    casper.start(rcloud_url, function () {
        casper.page.injectJs('jquery-1.10.2.js');
    });
    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);
    });

    //Create a new notebook
    functions.create_notebook(casper);

    casper.then(function(){
        temp  = functions.notebookname(casper);
        console.log('Getting notebook name');
    });
    casper.wait(2000);

    functions.fork(casper);

    casper.wait(2000);

    casper.then(function(){
        temp1 = functions.notebookname(casper);
        console.log('Getting notebook name after forking the current notebook');
    });

    casper.then(function(){
        if (temp == temp1){
            this.testfail('The name of the forked notebook is not fixed by a number in serial order');
        }else{
            this.test.pass('The name of the forked notebook is fixed by a number in serial order');
        }
    });

    casper.run(function () {
        test.done();
    });
});
示例#4
0
casper.test.begin("Assets contents as Searched text", 8, 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 search = 'GOOSEBUMP';//item to be searched
    var title;//get notebook title
    var notebookid = '75e0966de0bb185d7432';//to get the notebook id

	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);
    });
    
    //Loading Notebook 
    casper.viewport(1366, 768).thenOpen('http://127.0.0.1:8080/edit.html?notebook=' + notebookid, function () {
        this.wait(5000);
        this.waitForSelector({type: 'css', path: '#share-link .icon-share'}, function () {
            console.log("Verified that page is loaded successfully");
        });
    });

    functions.fork(casper);

    functions.addnewcell(casper);

    functions.addcontentstocell(casper, "INPUT_CODE");

    functions.search1(casper, search);

    casper.wait(5000);

    casper.then(function () {
        this.test.assertSelectorHasText(x(".//*[@id='0']/table/tbody/tr[2]/td/table/tbody/tr/td"), search, 'Assets contents as Searched text');
        
    });

    casper.run(function () {
        test.done();
    });
});
示例#5
0
casper.test.begin("Naming of the Imported Notebook in a folder", 8, 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 Notebook_ID = 'f5742eb70ddfc7e5b4cb';
    var Title;
    var New_Title;

    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);
    });
    
    //Loading a Imported notebook, which consists notebook name with prefix
    casper.then(function(){
		this.thenOpen('http://127.0.0.1:8080/edit.html?notebook='+Notebook_ID);
		this.wait(5000);
		functions.validation(casper);
	});
    
    casper.then(function(){
		Title = functions.notebookname(casper);
		this.echo("Present title of notebook: " + Title);
	});
	
	functions.fork(casper);
	
	casper.wait(2000).then(function(){
		this.wait(2000);
		var z = casper.evaluate(function triggerKeyDownEvent() {
            jQuery("#notebook-title").text("TESTING/NOTEBOOK_NAME_CHANGED");
            var e = jQuery.Event("keydown");
            e.which = 13;
            e.keyCode = 13;
            jQuery("#notebook-title").trigger(e);
            return true;
        });
        this.wait(3000);
        New_Title = functions.notebookname(casper);
        this.echo("Modified notebook title: " + New_Title);
        this.test.assertNotEquals(New_Title, Title, "the title has been successfully modified");
    });		
    
    functions.delete_notebooksIstarred(casper);

    casper.run(function () {
        test.done();
    });
});
示例#6
0
casper.test.begin("Open Notebook In Github after Forking", 14, 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 notebook_id = "82198d654e36c7e86761";//contains the notebook id to be searched
    var gist_owner;

    casper.start(rcloud_url, function () {
        casper.page.injectJs('jquery-1.10.2.js');
    });

    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);
    });

    casper.viewport(1366, 768).thenOpen('http://127.0.0.1:8080/view.html?notebook=' + notebook_id, function () {
        this.wait(7000);
        this.echo(this.getCurrentUrl());
    });

    casper.viewport(1366, 768).then(function () {
        this.test.assertUrlMatch(/view.html/, 'view.html page for given user loaded');
        //verify that only output div is visible and editable icon exists which proves that the notebook is currently not in Editable
        //form
        this.test.assertVisible('#edit-notebook > i:nth-child(1)', 'Edit option visible which proves that notebook currently is uneditable');
        this.test.assertNotVisible('div:nth-child(3) > div:nth-child(2) > pre:nth-child(2) > code:nth-child(1)', 'output div visible');
        this.test.assertNotVisible('div:nth-child(3) > div:nth-child(2) > pre:nth-child(1) > code:nth-child(1)', 'source code not visible');
    });

    //clicking on the Edit icon and verifying if the main.html page opens
    casper.viewport(1024, 768).then(function () {
        var z = casper.evaluate(function () {
            $('#edit-notebook').click();
        });
        this.wait(8000);
    });

    casper.viewport(1024, 768).then(function () {
        this.test.assertUrlMatch(/edit.html*/, 'main.html for the notebook has been loaded');
        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);
        this.wait(5000);
    });

    //fork the notebook
    functions.fork(casper);

    //open the notebook in Github 
    functions.open_advanceddiv(casper);
    casper.viewport(1366, 768).then(function () {

        this.waitForSelector({type: 'xpath', path: ".//*[@id='open_in_github']"}, function () {
            console.log("Link for opening notebook in github found. Clicking on it");

            if (this.click({type: 'xpath', path: ".//*[@id='open_in_github']"})) {

                this.wait(10000);
                /*this.waitForPopup(/gist.github.com/, function () {
                    this.test.assertEquals(this.popups.length, 2);
                });*/
                this.wait(11000);

                this.viewport(1366, 768).withPopup(/gist.github.com/, function () {
                    this.wait(4000);
                    console.log("The Github url opened: " + this.getCurrentUrl());
                    this.test.assertUrlMatch(/gist.github.com*/, 'Notebook opened in github');
                    //verifying that the gist opened belongs to different user
                    gist_owner = this.fetchText({type: 'css', path: '.url > span:nth-child(1)'});
                    this.wait(2000);
                    this.echo(gist_owner + ' is the current owner of the notebook');
                    this.test.assertEquals(gist_owner, github_username, 'hence confirmed that notebook opened as gist of local user');
                });

            }//if ends
            else {
                console.log('Notebook could not be opened in github');
            }
        });
    });


    casper.run(function () {
        test.done();
    });
});
示例#7
0
casper.test.begin("mini.html test", 8, 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 notebookid='f3480ceec707f5cbc84a';//to get the notebook id

    casper.start(rcloud_url, function () {
        functions.inject_jquery(casper);
    });

    casper.wait(10000);

    //login to Github and RCloud
    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);
        this.wait(4000);

    });

    casper.then(function () {
        this.thenOpen('http://127.0.0.1:8080/main.html?notebook=' + notebookid);
        this.wait(5000);
        this.test.assertVisible(x(".//*[@id='selection-bar']/div/div/input"), "Notebook opened");
    });


    functions.fork(casper);

    //Choosing mini from dropdown
    // casper.wait(3000).waitForSelector(x(".//*[@id='selection-bar']/div/div/input"), function () {
    //     this.click("span.dropdown");
    //     this.echo("Clicking on shareable dropdown menu button");

    //     this.waitForSelector("#view-type > li:nth-child(4) > a:nth-child(1)", function () {
    //         this.echo("mini option is visible");
    //         this.click("#view-type > li:nth-child(4) > a:nth-child(1)");
    //         console.log("Choosing 'mini' option from the dropdown'");
    //     });
    // });

    casper.then(function (){
        var URL = this.getCurrentUrl()
        this.echo(URL);
        var ID = URL.substring(41);
        this.echo(ID);
        this.thenOpen("http://127.0.0.1:8080/mini.html?notebook="+ID)
    })

    //Opening in mini.html
    casper.wait(5000).then(function () {
        this.test.assertUrlMatch(/mini.html/, 'mini.html link is opened');
        this.wait(5000);
        this.waitForSelector("body > h1:nth-child(1)", function () {
            this.test.assertExists("body > h1:nth-child(1)",'Required element found hence "Mini.html" notebook opened successfully');
            console.log("Confirmed Mini page opened");
        });    
    });

    casper.run(function () {
        test.done();
    });
});
示例#8
0
casper.test.begin("Fork Notebook and check if contents are editable", 15, 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 notebook_id = "7f90ae7dbe9fb01898f1";//contains the notebook id to be searched
    var input_code = "a<-50+50\n a";
    var expectedresult = "100\n"

    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);
    });

    //opening alien user's notebook
    casper.viewport(1366, 768).thenOpen('http://127.0.0.1:8080/view.html?notebook=' + notebook_id, function () {
        this.wait(11000);
        this.echo(this.getCurrentUrl());
        functions.viewhtml(casper);
    });

    //clicking on the Edit icon and verifying if the main.html page opens
    casper.viewport(1024, 768).then(function () {
        var z = casper.evaluate(function () {
            $('#edit-notebook').click();
        });
        this.wait(8000);
    });

    casper.viewport(1024, 768).then(function () {
        this.test.assertUrlMatch(/edit.html*/, 'main.html for the notebook has been loaded');
        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);
        this.wait(5000);
    });

    //checking if notebook title is editable
    casper.viewport(1366, 768).then(function () {
        if (this.test.assertExists(x(".//*[@id='readonly-notebook']"))) {
            this.echo("Notebook title is uneditable");
        }
        else {
            this.echo("Notebook title is editable")
        }
    });

    //fork the notebook
    functions.fork(casper);

    //checking if command prompt is visible and whether new code can be entered. This is a validation to check 
    //if contents of notebook are in editable form
    casper.wait(5000).viewport(1366, 768).then(function () {
        this.test.assertVisible(x(".//*[@id='command-prompt']/div[2]/div"), 'option present to enter contents. Hence notebook is editable.');
        functions.runall(casper);//this is done so that we can insert code in the newly created cell
    });

    functions.addnewcell(casper);
    casper.then(function () {
        this.echo("successfully created a new cell. hence confirmed that notebook content can be modified");
    });

    casper.run(function () {
        test.done();
    });
});
示例#9
0
casper.test.begin("Upload a file to another user's notebook after forking it ", 8, 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 new_username = '******';
    var new_user_password = '******';
    var notebook_id, URL, before_forking ;
    var res1 = 'disabled';// to compare with res
    var fileName = "SampleFiles/PHONE.csv";
    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.waitUntilVisible('#run-notebook', function () {
        this.echo('waiting for page to open completely');
    });

    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);
    });

    //Create a new Notebook.
    functions.create_notebook(casper);

    casper.then(function () {
        URL = this.getCurrentUrl();
    });

    // Getting the title of new Notebook
    casper.then(function () {
        before_forking = this.fetchText('#notebook-author');
        console.log("Notebook owner after forking = " + before_forking);
        initial_title = functions.notebookname(casper);
        this.echo("New Notebook title : " + initial_title);
    });

    //getting Notebook ID
    casper.viewport(1024, 768).then(function () {
        var temp1 = this.getCurrentUrl();
        notebookid = temp1.substring(41);
        this.echo("The Notebook Id: " + notebookid);
    });

    //loging out of RCloud
    casper.viewport(1366, 768).then(function () {
        test.comment('⌚️  Logging out of RCloud and GitHub to check shareable links for anonymous usere ...');
        this.wait(13000)
        // console.log('Logging out of RCloud');
        this.click("#rcloud-navbar-menu > li:nth-child(7) > a:nth-child(1)");
    });

    casper.then(function () {
        this.wait(7000);
        this.click('#main-div > p:nth-child(2) > a:nth-child(2)')
    });
    casper.then(function () {
        this.wait(7000);
        this.click('.btn');
        this.wait(4000);
    });

    casper.wait(3000);

    //Login to RCloud with new user
    casper.then(function () {
        test.comment('⌚️  Logging in with the another user credentials ...');
        this.thenOpen('http://127.0.0.1:8080/login.R');
        this.wait(13000);
        functions.login(casper, new_username, new_user_password, rcloud_url);
    });

    casper.then(function () {
        this.thenOpen(URL);
        this.wait(8000);
    });

    casper.then(function () {
        console.log('Checking whether user is able to upload files to notebook or not by fetching element info')
        var temp = this.getElementInfo('#upload-to-notebook').tag;
        this.echo(temp);
        var res = temp.substring(17, 25);

        this.echo(res);
        this.test.assertEquals(res1, res, "For unforked Notebooks file uploaad to notebook is disabled")
    })

    functions.fork(casper);

    casper.then(function () {
        casper.page.uploadFile("#file", fileName);
        console.log('Selecting a file');
    });

    casper.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.then(function () {
        this.wait(5000);
        this.waitUntilVisible(x('//*[contains(text(), "added")]'), function then() {
            console.log("File has been uploaded");
        });
    });

    casper.then(function () {
        console.log('Verifying whether the uploaded contentsa are present in Asset div or not');
        this.test.assertSelectorHasText(x(".//*[@id='asset-list']/li[3]/a/span[1]"), 'PHONE.csv', 'After forking, file can be uploaded and Uploaded file is present in assets');
    });

    casper.run(function () {
        test.done();
    });
});
示例#10
0
casper.test.begin("flexdashboard.html notebook opening as a Anonymous user", 10, 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.js'));
    var notebook_id;
    var ID;
    
    casper.start(rcloud_url, function () {
        functions.inject_jquery(casper);
    });

    casper.wait(10000);

    //Login to GitHub and RCloud
    casper.viewport(1024, 768).then(function () {
        functions.login(casper, github_username, github_password, rcloud_url);
    });

    //Validating for RCloud main page to be loaded
    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);
    });


    casper.then(function () {
        this.thenOpen('http://127.0.0.1:8080/main.html?notebook=5155a7c1de42e7fb64fc5cb09a28c4b5');
        this.wait(5000);
        this.test.assertVisible(x(".//*[@id='selection-bar']/div/div/input"), "Notebook opened");
    });
    
    casper.wait(4000);

    functions.fork(casper);

    casper.wait(4000);
    
    casper.wait(9000).then(function (){
        var URL = this.getCurrentUrl()
        this.echo(URL);
        var ID = URL.substring(41);
        this.echo(ID);
        this.thenOpen(URL);
    });
    
    casper.wait(4000);
    
    casper.wait(6000).then(function () {
		this.click(x(".//*[@id='rcloud-navbar-menu']/li[3]/a/b"));
        console.log("Opening dropdown");
        this.click(x(".//*[@id='publish_notebook']/i"));
        console.log("Publishing Notebook");
        this.wait(4000);
    });
    
    casper.wait(9000).then(function (){
        var URL = this.getCurrentUrl()
        this.echo(URL);
        var ID = URL.substring(41);
        this.echo(ID);
    });

    //logging out of RCloud
    casper.viewport(1366, 768).then(function () {
        console.log('Logging out of RCloud');
        this.click("#rcloud-navbar-menu > li:nth-child(7) > a:nth-child(1)");
        this.wait(6000);
    });


    //Accessing flexdashboard.html for published notebook as anonymous user
    casper.wait(4000).then(function (){
        this.thenOpen("http://127.0.0.1:8080/shared.R/rcloud.flexdashboard/flexdashboard.html?notebook=" + ID);
    });

    //Opening in flexdashboard.html
    casper.wait(9000).then(function () {
        this.test.assertUrlMatch(/flexdashboard.html/, 'flexdashboard.html link is opened');
        this.wait(8000);
    });
    

    casper.wait(4000);
    
    casper.wait(6000).then(function (){
        this.page.switchToChildFrame(0);
            casper.withFrame(0,function() {
                this.test.assertExists(".navbar-brand", "Navigation bar exists");
                this.test.assertSelectorHasText("#lung-deaths-all > div:nth-child(1)", "Lung Deaths (All)");
                this.test.assertVisible("#lung-deaths-all > div:nth-child(2)", "desired element is visible");
        });        
        this.page.switchToParentFrame();
    });
    
    casper.run(function () {
        test.done();
    });
});
示例#11
0
casper.test.begin(" For non Executed cell, status will be Open circle", 6, 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 temp, res;
    var actual_res = 'icon-circle-blank';
    var notebook_id = "95a75c9f62f95adc2469";//slow notebook id
    var errors = [];
        
    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);
    });
    
    //open notebook belonging to some different user
    casper.then(function (){
        this.thenOpen('http://127.0.0.1:8080/main.html?notebook=' + notebook_id);
    });

    casper.wait(5000).then( function (){
         title = functions.notebookname(casper);
        this.echo("Notebook title : " + title);
        this.wait(3000);
    });
    
    functions.fork(casper);
    
    //Fetching the elemnt information and comparing with the var status
	casper.wait(4000).then(function () {
		var temp = this.getElementInfo(x(".//*[@id='part2.R']/div[2]/div[1]/span[3]/i")).tag;
		res = temp.substring(45, 62);
		this.echo('Cureents cell status is :' +res );
	});
	
	casper.then(function(){
		if (actual_res == res)
		{
			this.test.pass('For non Executed cell, status will be:' +res);
		}else
		{
			this.test.fail('Failed to fetch the cell details');
		}
	});
	
	//Registering to the page.errors actually not required but still if there are some errors found on the page it will gives us the details
    casper.on("page.error", function(msg, trace) {
        this.echo("Error:    " + msg, "ERROR");
        this.echo("file:     " + trace[0].file, "WARNING");
        this.echo("line:     " + trace[0].line, "WARNING");
        this.echo("function: " + trace[0]["function"], "WARNING");
        errors.push(msg);
    });

    casper.run(function() {
        if (errors.length > 0) {
            this.echo(errors.length + ' Javascript errors found', "WARNING");
        } else {
            this.echo(errors.length + ' Javascript errors found', "INFO");
        }
        test.done();
    });
});
示例#12
0
 casper.then(function () {
     this.wait(2000);
     functions.fork(casper);
 });
示例#13
0
casper.test.begin("View history versions of the notebook(after fork)", 16, 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 new_username = '******';
    var new_user_password = '******';
    var notebook_id, before, input = 'a<-12; b<-12; c<-12', comment = 'Manikandan P';
    var input2 = 'c<-12; d<-a+b+c; d';
    var notebook_status = '(read-only)';

    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.waitUntilVisible('#run-notebook', function () {
        this.echo('waiting for page to open completely');
    });

    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);
    });

    //Create a new Notebook.
    functions.create_notebook(casper);

    // Getting the title of new Notebook
    casper.then(function () {
        before = this.fetchText('#notebook-author');
        console.log("Author of the Notebook : " + before);
        initial_title = functions.notebookname(casper);
        this.echo("New Notebook title : " + initial_title);
    });

    //getting Notebook ID
    casper.viewport(1024, 768).then(function () {
        var temp1 = this.getCurrentUrl();
        notebook_id = temp1.substring(41);
        this.echo("The Notebook Id: " + notebook_id);
    });

    //Creating cell and adding contents to it
    functions.addnewcell(casper);
    functions.addcontentstocell(casper, input);
    functions.comments(casper, comment);
    functions.comments(casper, "WildCraft");
    
    //Creating one more cell
    casper.then(function () {
        this.click({type:'xpath', path:".//*[@id='prompt-area']/div[1]/div/span/i"});
        console.log('Creating one more cell');
        this.wait(2000);
	});
	
	//Adding contents to the newly created cell
	casper.then(function () {
        this.sendKeys({
            type: 'xpath',
            path: ".//*[@id='part2.R']/div[3]/div[1]/div[2]/div/div[2]/div"
        }, input2);
        
        functions.runall(casper);
    });

        //logout of RCloud & Github
    casper.then(function(){
        this.click("#rcloud-navbar-menu > li:nth-child(7) > a:nth-child(1)");
        console.log('Logging out of RCloud');
        this.echo(this.getTitle());
    });

    casper.wait(5000);

    casper.viewport(1366, 768).then(function () {
        this.click(x('/html/body/div[2]/p[2]/a[2]'));
        console.log('Logging out of Github');
        this.wait(12000);
    });

    casper.viewport(1366, 768).then(function () {
        this.waitForSelector('.btn', function () {
            this.click(".btn");
            console.log('logged out of Github');
        });
        this.wait(7000);
        this.echo("The url after logging out of Github : " + this.getCurrentUrl());
        this.waitForSelector("a.btn:nth-child(1)", function (){
            this.wait(3000);
            this.test.assertTextExists('GitHub', "Confirmed that successfully logged out of Github");
            this.echo(this.getTitle());
        });  
    });

    casper.wait(3000);

    //Login to RCloud with new user
    casper.then(function () {
        this.thenOpen('http://127.0.0.1:8080/login.R');
        this.wait(13000);
        functions.login(casper, new_username, new_user_password, rcloud_url);
    });

    casper.then(function () {
        var url = this.getCurrentUrl();
        this.thenOpen(url);
        this.wait(5000);
    });

    casper.then(function () {
        functions.open_advanceddiv(casper);
        this.echo("Clicking on dropdown");
        this.wait(2999);
        casper.setFilter("page.prompt", function (msg, currentValue) {
            if (msg === "Enter notebook ID or github URL:") {
                return notebook_id;
            }
        });
        this.click("#open_from_github");
        this.echo("Opening Notebook using Load Notebook ID");
        this.wait(10000);
    });

    casper.then(function () {
        var temp = this.fetchText({type: 'css', path: "#readonly-notebook"});
        this.test.assertEquals(temp, notebook_status, "The notebook which belongs to other user is loaded in Read Only Mode");
    });

    casper.then(function () {
        var star = this.fetchText({
            type: 'css',
            path: ".jqtree-selected > div:nth-child(1) > span:nth-child(2) > span:nth-child(2) > span:nth-child(1) > sub:nth-child(2)"
        });
        this.echo('Star count of the notebook is :' + star + 'which belongs to ' + before + ' user ');
    });

    //Check for notebook history 
    casper.then(function () {
        if (this.test.assertVisible({type: 'css', path: '.jqtree-selected > div:nth-child(1) > span:nth-child(1)'})) {
            console.log('selected notbook found');
            this.mouse.move('.jqtree-selected > div:nth-child(1) > span:nth-child(1)');
            this.waitUntilVisible(('.jqtree-selected > div:nth-child(1) > span:nth-child(2) > span:nth-child(3) > span:nth-child(1) > span:nth-child(2) > i:nth-child(1)'), function () {
                this.wait(2000);
                this.click('.jqtree-selected > div:nth-child(1) > span:nth-child(2) > span:nth-child(3) > span:nth-child(1) > span:nth-child(2) > i:nth-child(1)');
                console.log("clicking on notebook History icon");
                this.wait(3000);
            });
        } else {
            console.log("Notebook not found");
        }
    });
    
    casper.then(function () {
        var temp = this.fetchText({
            type: 'css',
            path: '.jqtree-selected > ul:nth-child(2) > li:nth-child(1) > div:nth-child(1) > span:nth-child(1)'
        });
        this.echo('History liknk for the Notebook is: ' + temp);
        if (this.exists({
                type: 'css',
                path: '.jqtree-selected > ul:nth-child(2) > li:nth-child(1) > div:nth-child(1) > span:nth-child(1)'
            }, "Verifying for history links")) {
            this.test.pass("History link present");
        }
        else {
            this.test.fail("History link is not present");
        }
    });
    
    functions.fork(casper);
    
    casper.then(function () {
        if (this.test.assertVisible({type: 'css', path: '.jqtree-selected > div:nth-child(1) > span:nth-child(1)'})) {
            console.log('selected notbook found');
            this.mouse.move('.jqtree-selected > div:nth-child(1) > span:nth-child(1)');
            this.waitUntilVisible(('.jqtree-selected > div:nth-child(1) > span:nth-child(2) > span:nth-child(3) > span:nth-child(1) > span:nth-child(2) > i:nth-child(1)'), function () {
                this.wait(2000);
                this.click('.jqtree-selected > div:nth-child(1) > span:nth-child(2) > span:nth-child(3) > span:nth-child(1) > span:nth-child(2) > i:nth-child(1)');
                console.log("clicking on notebook History icon");
            });
        } else {
            console.log("Notebook not found");
        }
    });

    casper.wait(8000);
    
    casper.then(function () {
        this.waitForSelector(".jqtree-selected > ul:nth-child(2) > li:nth-child(1) > div:nth-child(1) > span:nth-child(1)");
        var temp = this.fetchText({
            type: 'css',
            path: '.jqtree-selected > ul:nth-child(2) > li:nth-child(1) > div:nth-child(1) > span:nth-child(1)'
        });
        this.echo('History liknk for the Notebook is: ' + temp);
        if (this.exists({
                type: 'css',
                path: '.jqtree-selected > ul:nth-child(2) > li:nth-child(1) > div:nth-child(1) > span:nth-child(1)'
            }, "Verifying for history links")) {
            this.test.pass("History link present");
        }
        else {
            this.test.fail("History link is not present");
        }
    });
    casper.run(function () {
        test.done();
    });
});
示例#14
0
casper.test.begin(" Cell status for a successfully executed cell", 6, 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 temp, res;
    var actual_res = 'icon-circle';
    var notebook_id = "aee32afd46a8daece207d5812b72c8a4";//slow notebook id
    
    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);
    });
    
    //open notebook belonging to some different user
    casper.then(function (){
        this.thenOpen('http://127.0.0.1:8080/main.html?notebook=' + notebook_id);
    });

    casper.wait(5000).then( function (){
         title = functions.notebookname(casper);
        this.echo("Notebook title : " + title);
        this.wait(3000);
    });
    
    functions.fork(casper);
    
    functions.runall(casper);
    
    //Fetching the elemnt information and comparing with the var status
	casper.then(function () {
		var temp = this.getElementInfo(x(".//*[@id='part1.R']/div[2]/div[1]/span[3]/i")).tag;
		// this.echo(temp);
		res = temp.substring(75, 86);
		this.echo('Currents cell status is :' +res );
	});
	
	casper.then(function(){
		if (actual_res == res)
		{
			this.test.pass('status for successfully executed cell will be:' +res);
		}else
		{
			this.test.fail('Failed to fetch the cell details');
		}
	});

    casper.run(function() {
        test.done();
    });
});