Skip to content

Instantly share code, notes, and snippets.

@tredence123
Created April 17, 2015 10:34
Show Gist options
  • Select an option

  • Save tredence123/18cedde89e7b09820446 to your computer and use it in GitHub Desktop.

Select an option

Save tredence123/18cedde89e7b09820446 to your computer and use it in GitHub Desktop.
sample
casper.test.begin("Pre executed two or more R cells and Rmarkdown cells to be executed using Run All", 12, 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 input_code = "50+50" ;
var expected_result = "100";
var errors = [];
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(){
this.click({type:'xpath', path:"/html/body/div[3]/div/div[2]/div/div[3]/div[1]/div/span/i"});//creating 1st R cell
this.wait(3000);
var form = document.evaluate(".//*[@id='part1.R']/div[2]/div[2]/select", document, null,XPathResult.FIRST_ORDERED_NODE_TYPE);
});
casper.wait(10000);
casper.run(function () {
test.done();
});
});
@artjomb
Copy link

artjomb commented Apr 17, 2015

You should use

this.wait(3000, function(){
  this.echo(this.evaluate(function(){
    return !!document.evaluate("//*[@id='part1.R']/div[2]/div[2]/select", document, null,XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; });
  }));
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment