Skip to content

Instantly share code, notes, and snippets.

View maggiesavovska's full-sized avatar

Maggie Jones Savovska maggiesavovska

View GitHub Profile
@maggiesavovska
maggiesavovska / gist:524467ff5ab10fb0081c
Last active August 29, 2015 14:02
common useful JS code snippets
for (var property in object) {
if (object.hasOwnProperty(property)) {
// do stuff
}
}
@maggiesavovska
maggiesavovska / smartScreenshot.js
Created May 23, 2016 06:23
Scroll and take screenshots
exports.smartScreenshot = function(driver, filepath){
return new Promise(function(resolve, reject){
function scrollAndShoot(position, iteration, repetitions, viewHeight){
driver.scroll(0, position).then(function(){
var p = filepath + '_' + iteration + '.png';
driver.saveScreenshot(p).then(function(){
iteration++;
if(iteration > repetitions){
//todo
//https://wiki.saucelabs.com/display/DOCS/Annotating+Tests+with+the+Sauce+Labs+REST+API
13:47:51.326 INFO - Executing: [new session: Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@79c21fba, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=webdriverio, version=4.2.1, url=http://webdriver.io}}]])
13:47:51.327 INFO - Creating a new session for Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@79c21fba, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=webdriverio, version=4.2.1, url=http://webdriver.io}}]
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 33758
Only local connections are allowed.
13:47:52.107 INFO - Done: [new session: Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@79c21fba, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=webdrive
@maggiesavovska
maggiesavovska / gist:f85869d687234c498cef24e8f849d028
Created August 1, 2016 11:55
it('should click button', function(done){ driver.element('.cbProductAdd').then(function(result){ driver.moveTo(result.value.ELEMENT, 40, 10).then(function(){ driver.pause(10000).then(function(){ driver.buttonPress().then(function(){ console.log('bp done'); done(); }); }); }).catch(function(err){console.log(err.message)}); }); });
13:52:11.826 INFO - Executing: [new session: Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@34e7ed2e, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=webdriverio, version=4.2.1, url=http://webdriver.io}}]])
13:52:11.828 INFO - Creating a new session for Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@34e7ed2e, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=webdriverio, version=4.2.1, url=http://webdriver.io}}]
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 13168
Only local connections are allowed.
13:52:12.538 INFO - Done: [new session: Capabilities [{rotatable=true, locationContextEnabled=true, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@34e7ed2e, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=webdrive
@maggiesavovska
maggiesavovska / Dockerfile
Last active October 10, 2016 19:51
getting started with docker
FROM node:argon
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
@maggiesavovska
maggiesavovska / recursivefs.js
Last active January 14, 2017 16:25
node.js recursive function to read all files in directory (searches through all directories to find files)
//******************************************************/
//Include all files going one directory deep
//* @param {String} d - directory name of directory where search is occurring
//* @param {Array || String} exclude - array of file names {STRING} to skip
//******************************************************/
function fileSearch(d, exclude){
var exclude = exclude || [];
@maggiesavovska
maggiesavovska / child.js
Created March 7, 2017 19:15
pm2 launchBus() child process sending message after exit
process.send({
type : 'process:msg',
data : {id:process.pid}
});
process.disconnect();
process.exit();
@maggiesavovska
maggiesavovska / actionsApi.txt
Last active March 26, 2018 18:42
Summary of sendKeys() and moveTo() Issues
Bunch of stuff broken? Don't fear..the Actions API is on it's way and it will probably be a good thing! Chin up!
OVERVIEW:
The purpose of this document is to explain the new actions API and what it has to do with certain commands
such as moveto and keys being depricated in webdriverio (due to them being deprecated in certain browser drivers).
MAIN ISSUE:
1. The issue is that these new drivers suppress these commands on purpose because they are deprecated,
but the drivers have not yet implemented the new WC3 standard called "actions API".
"The user-facing API for emulating complex user gestures. Use this class rather than using the Keyboard or Mouse directly."
@maggiesavovska
maggiesavovska / appiummac.md
Created May 31, 2017 20:29
Setting Up Appium on Mac
  1. Set up for Appium:
@maggiesavovska
maggiesavovska / gist:b16da0b662af5ac599261e82ebd35e09
Last active June 8, 2017 19:28
webdriverio - integrating with crossbrowsertesting.com
1) Include the following in your webdriverio config
NOTE: max_duration is specific to crossbrowsertesting.com.
cbt will time out any test after 10 minutes unless you pass a "max_duration"
value in your capabilities.
desiredCapabilities: {max_duration:[[amount in seconds]]}
const cbtConfig = {
host: "hub.crossbrowsertesting.com",
port: 80,
user: [[INSERT YOUR USER NAME HERE]],