Beispiel #1
0
module.exports = function (argument) {
	var myActions = browserActions.CreateBrowserActions(); 

	this.Given(/^The browser is open to the calendar page$/, function (callback) {
	  this.driver.getTitle().then(function (title) {
	  	assert.equal(title,myActions.pageTitle_calendar,'expected page title: <'+myActions.pageTitle_calendar+'> actual: <'+title+'>');
		  callback();
	  });
	});

	/*
		Workouts are added individually in the recordWorkouts.js step definition file
	*/

	this.When(/^Inspects workout that was just added$/, function (callback) {
	  /*
			This step assumes workout being inspected is most recent workout
	  */ 
	  this.driver.sleep(1500); //this is needed for the element to be rendered
	  debugger;
	  this.driver.executeScript('document.getElementsByClassName(\'workoutDiv\')[document.getElementsByClassName(\'workoutDiv\').length-1].click()').
	  then(function () {
	  	callback();
	  });
	});

	this.Then(/^the tTSS score should equal (\d+)$/, function (arg1, callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.findElement({id:'tssCompletedField'}).
	  	getAttribute('value').
	  	then(function (tTSS) {
	  		assert(tTSS,arg1,'expected tTSS: <'+arg1+'> actual <'+tTSS+'>');
			  callback();
  	});
	});

	this.Then(/^Delete workout$/, function (callback) {
  // Write code here that turns the phrase above into concrete actions
  	this.driver.sleep(1000);
	  this.driver.findElement({id:'delete'}).click();
	  this.driver.findElement({id:'userConfirm'}).click().then(function () {
		  callback();
	  });
	});
};
Beispiel #2
0
module.exports = function (){
	var myActions = model.CreateBrowserActions(); 
	var workouts = model.CreateWorkouts();

	this.When(/^User adds RUN with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Run future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.run.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.run.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});
	});

	this.When(/^User adds BIKE with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
		
    console.log('1');
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
    console.log('2');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Bike future\')[0].click()'); //mod
    console.log('3');
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.bike.duration);	//mod
    console.log('4');
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.bike.heartRateThreshold); //mod
    console.log('5');
		this.driver.sleep(5000);
    console.log('6');
		this.driver.findElement({id:'close'}).then(function (closeButton) {
			console.log('closeButton.isDisplayed(): '+closeButton.isDisplayed());
			return closeButton.click();
		})
		/*
			After clicking the close button there might be a pop up that says "You have unsaved changes on your workout. Would you like to save these changes". The options are:
				"Yes"(button data-action="save") 
				"No"(button data-action="undo") 
				"Cancel"(button id="userCancel") 
		*/
			.then(function () {											
		  callback();
		});
    console.log('7');
	});

	this.When(/^User adds SWIM with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Swim future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.swim.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.swim.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});
	});

	this.When(/^User adds CROSSTRAIN with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Crosstrain future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.crosstrain.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.crosstrain.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});		
	});

	this.When(/^User adds MOUNTAINBIKE with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout MountainBike future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.mountainbike.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.mountainbike.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});
	});

	this.When(/^User adds STRENGTH with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Run future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.run.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.run.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});
	});

	this.When(/^User adds CUSTOM with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Strength future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.strength.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.strength.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});
	});

	this.When(/^User adds XC\-SKI with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout XC-Ski future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.xcski.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.xcski.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});;
	});

	this.When(/^User adds ROWING with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Rowing future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.rowing.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.rowing.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});
	});

	this.When(/^User adds OTHER with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Other future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.other.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.other.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});
	});

	this.When(/^User adds WALK with heartrate and duration$/, function (callback) {
	  // Write code here that turns the phrase above into concrete actions
	  this.driver.executeScript('document.getElementsByClassName(\'addWorkout\')[70].click()');
		this.driver.executeScript('document.getElementsByClassName(\'addWorkout Walk future\')[0].click()'); //mod
		this.driver.findElement({id:'totalTimeCompletedField'}).sendKeys(workouts.walk.duration);	//mod
		this.driver.findElement({id:'hrAvgField'}).sendKeys(workouts.walk.heartRateThreshold); //mod
		this.driver.findElement({id:'close'}).click().then(function () {
		  callback();
		});
	});
};