Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akshay-bhardwaj/8859857 to your computer and use it in GitHub Desktop.
Save akshay-bhardwaj/8859857 to your computer and use it in GitHub Desktop.
/*
* require, fs, wd, assert, colors
* saves screenshot in current folder as hello.png
*/
var fs = require('fs');
module.exports = function helloBrowserStack(browser, cb) {
browser.get("http://www.google.com", function() {
browser.title(function(err, title) {
browser.elementByName('q', function(err, el) {
el.sendKeys("BrowserStack", function() {
browser.elementByName("btnG", function(err,el) {
el.click(function() {
browser.takeScreenshot(function(err, res){
data = new Buffer(res, 'base64');
fdr = fs.openSync("hello.png", 'w');
fs.writeSync(fdr,data,0,data.length);
browser.quit();
})
})
})
})
})
})
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment