Added Fix for Protractor Test

This commit is contained in:
Jesse 2015-08-07 11:28:18 -07:00 committed by Victor Woeltjen
parent 7ded288154
commit ef7c1bd025
11 changed files with 405 additions and 43 deletions

60
protractor/README Normal file
View File

@ -0,0 +1,60 @@
E2e Protractor Tests.
1. Instructions:
1. ctrl.sh: contains start up, stop, and run scripts.
* May need to modify DIRECTORY variable to reflect location of MMAP. *
-start: This will start 3 processes: MMAP, webdriver, and elastic search, all 3 are needed.
-run: run will run the protractor tests. (protractor conf.js)
-stop: stop will kill the 3 process started by the start command.
2. example:
cd protractor
./ctrl.sh start
./ctrl.sh run
*Note: multiple test can be run at this point.
./ctrl.sh stop
2. Directory Hierachy:
-protractor: base directory
-common: contains prototype javascript functions that all other tests use.
-Buttons: common prototype functions related to enter fullscreen
-CreateItem: common prototype functions related to creating an item
-drag: common functions to test drag and drop.
-editItem: common functions used to test edit functionality.
-RightMenu: common functions for right click menu(remove).
-create
-e2e tests that creates the specified object.
-delete
-e2e tests that removes the specified object
-logs
-ctrl.sh redirects console output of MMAP, webdriver and elastic search and pipes them to log files.
-UI
-Contains tests that test the UI(drag drop, fullscreen, info bubble)
-conf.js:
-protractor config file. Explained below
3. Conf.js
Conf.js is used by protractor to setup and execute the tests.
-allScriptsTimeout: gives more time for protractor to synchronize with the page.
-jasmineNodeOpts: Protractor uses jasmine for the tests and jasmine has a default time out 30 seconds
per "it" test. Changed to maximume allowed time 360000 ms
-seleniumAddress: Protractor uses a Selenium server as a "proxy" between the test scripts and the browser
driver. A stand a lone version comes with protractor and to run use "webdriver-manager"
default address is: http://localhost:4444/wd/hub.
-specs[]: Is an array of files. Each File should have a "describe, it" test to be executed by protractor.
-capabilities: Tells protractor what browser to use and any browser arguments.
4. StressTest:
Tests that are used to test for memory leaks. You can use the new tab option on WARP and then open the
timeline in the new tab during the browser.sleep(). Once the test is do the browser will pause and you can
look a the timeline results in the new tab.
NOTE: Cannot open chrome dev tools on same tab as the test are run on. Protractor uses the dev tools to
exectute the tests.
-StressTest will create and delete folders.
-StressTestBubble.js: creates manny bubbles.
(Delay variable in InfoGesture.js was changed to 0)

View File

@ -19,7 +19,6 @@
* this source code distribution or the Licensing information page available * this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
//TODO Add filter for duplications/
var itemCreate = require("./common/CreateItem"); var itemCreate = require("./common/CreateItem");
var itemEdit = require("./common/EditItem"); var itemEdit = require("./common/EditItem");
var right_click = require("./common/RightMenu.js"); var right_click = require("./common/RightMenu.js");
@ -41,31 +40,35 @@ describe('Create Folder', function() {
}); });
it('should Create new Folder', function(){ it('should Create new Folder', function(){
browser.sleep(5000); browser.sleep(5000);
for(var i=0; i < 50; i++){ for(var i=0; i < 25; i++){
browser.wait(function() { browser.wait(function() {
createClass.createButton().click(); createClass.createButton().click();
return true; return true;
}).then(function (){ }).then(function (){
var folder = createClass.selectNewItem(ITEM_TYPE); var folder = createClass.selectNewItem(ITEM_TYPE);
expect(folder.getText()).toEqual([ ITEM_MENU_GLYPH ]); expect(folder.getText()).toEqual([ ITEM_MENU_GLYPH ]);
browser.sleep(1000); browser.sleep(500);
folder.click() folder.click()
}).then(function() { }).then(function() {
browser.wait(function () { browser.wait(function () {
return element.all(by.model('ngModel[field]')).isDisplayed(); return element.all(by.model('ngModel[field]')).isDisplayed();
}) })
createClass.fillFolderForum(ITEM_NAME, ITEM_TYPE).click(); createClass.fillFolderForum(ITEM_NAME, ITEM_TYPE).click();
browser.sleep(1000); browser.sleep(500);
}).then(function (){ }).then(function (){
browser.sleep(1000); browser.sleep(500);
// if(i === 1){
clickClass.delete(ITEM_SIDE_SELECT, true); clickClass.delete(ITEM_SIDE_SELECT, true);
element.all(by.css('.ui-symbol.view-control.ng-binding.ng-scope')).click(); //element.all(by.css('.ui-symbol.view-control.ng-binding.ng-scope')).click();
// }else{
browser.sleep(1000);
var MyItem = ">\nF\nMy Items"
element.all(by.repeater('child in composition')).filter(function (ele){
return ele.getText().then(function(text) {
//expect(text).toEqual(MyItem);
return text === MyItem;
});
}).all(by.css('.ui-symbol.view-control.ng-binding.ng-scope')).click();
// clickClass.delete(ITEM_SIDE_SELECT, false); // clickClass.delete(ITEM_SIDE_SELECT, false);
// }
}); });
} }
browser.pause(); browser.pause();

View File

@ -0,0 +1,59 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/StressTestBubble.jsStressTestBubble.js
var itemCreate = require("./common/CreateItem");
var itemEdit = require("./common/EditItem");
var right_click = require("./common/RightMenu.js");
describe('Create Folder', function() {
var clickClass = new right_click();
var createClass = new itemCreate();
var editItemClass = new itemEdit();
var ITEM_NAME = "Folder";
var ITEM_TYPE = "folder";
var ITEM_MENU_GLYPH = 'F\nFolder';
var ITEM_GRID_SELECT = 'P\nF\nFolder\n0 Items';
var ITEM_SIDE_SELECT = ">\nF\nFolder"
beforeEach(function() {
browser.ignoreSynchronization = true;
browser.get('http://localhost:1984/warp/');
browser.sleep(2000); // 20 seconds
});
it('should Create new Folder', function(){
browser.sleep(10000);
for(var i=0; i < 1000; i++){
var object = element.all(by.repeater('child in composition')).filter(function (ele){
return ele.getText().then(function(text) {
return text === ">\nF\nMy Items";
});
});
//browser.sleep(1000)
browser.actions().mouseMove(object.get(0)).perform();
//browser.actions().click(protractor.Button.RIGHT).perform();
element.all(by.css('.items-holder.grid.abs.ng-scope')).click();
}
browser.pause();
});
});

View File

@ -0,0 +1,56 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
var itemCreate = require("./common/CreateItem");
var itemEdit = require("./common/EditItem");
var right_click = require("./common/RightMenu.js");
describe('Create Folder', function() {
var clickClass = new right_click();
var createClass = new itemCreate();
var editItemClass = new itemEdit();
var ITEM_NAME = "Folder";
var ITEM_TYPE = "folder";
var ITEM_MENU_GLYPH = 'F\nFolder';
var ITEM_GRID_SELECT = 'P\nF\nFolder\n0 Items';
var ITEM_SIDE_SELECT = ">\nF\nFolder"
beforeEach(function() {
browser.ignoreSynchronization = true;
browser.get('http://localhost:1984/warp/');
browser.sleep(2000); // 20 seconds
});
it('should Create new Folder', function(){
browser.sleep(10000);
for(var i=0; i < 1000; i++){
createClass.createButton().click();
//browser.sleep(1000)
//browser.actions().mouseMove(object.get(0)).perform();
//browser.actions().click(protractor.Button.RIGHT).perform();
element.all(by.css('.items-holder.grid.abs.ng-scope')).click();
}
browser.pause();
});
});

View File

@ -0,0 +1,55 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
var itemCreate = require("./common/CreateItem");
var itemEdit = require("./common/EditItem");
var right_click = require("./common/RightMenu.js");
describe('Create Folder', function() {
var clickClass = new right_click();
var createClass = new itemCreate();
var editItemClass = new itemEdit();
var ITEM_NAME = "Folder";
var ITEM_TYPE = "folder";
var ITEM_MENU_GLYPH = 'F\nFolder';
var ITEM_GRID_SELECT = 'P\nF\nFolder\n0 Items';
var ITEM_SIDE_SELECT = ">\nF\nFolder"
beforeEach(function() {
browser.ignoreSynchronization = true;
browser.get('http://localhost:1984/warp/');
browser.sleep(2000); // 20 seconds
});
it('should Create new Folder', function(){
browser.sleep(10000);
for(var i=0; i < 1000; i++){
browser.wait(function() {
createClass.createButton().click();
return true;
}).then(function (){
element.all(by.css('.items-holder.grid.abs.ng-scope')).click();
})
}
browser.pause();
});
});

View File

@ -0,0 +1,61 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
var itemCreate = require("./common/CreateItem");
var itemEdit = require("./common/EditItem");
var right_click = require("./common/RightMenu.js");
var fullScreenFile = require("./common/FullScreen");
describe('Create Folder', function() {
var clickClass = new right_click();
var createClass = new itemCreate();
var editItemClass = new itemEdit();
var fullScreenClass = new fullScreenFile();
var ITEM_NAME = "Folder";
var ITEM_TYPE = "folder";
var ITEM_MENU_GLYPH = 'F\nFolder';
var ITEM_GRID_SELECT = 'P\nF\nFolder\n0 Items';
var ITEM_SIDE_SELECT = ">\nF\nFolder"
beforeEach(function() {
browser.ignoreSynchronization = true;
browser.get('http://localhost:1984/warp/');
browser.sleep(2000); // 20 seconds
});
it('should Create new Folder', function(){
browser.sleep(15000);
for(var i=0; i < 1000; i++){
fullScreenClass.newWidnow().click();
browser.getAllWindowHandles().then(function (handles) {
//browser.driver.switchTo().window(handles[1]);
browser.sleep(1000);
browser.driver.close();
browser.sleep(1000);
// browser.driver.switchTo().window(handles[0]);
});
}
browser.pause();
});
});

View File

@ -0,0 +1,59 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
var itemCreate = require("./common/CreateItem");
var itemEdit = require("./common/EditItem");
var right_click = require("./common/RightMenu.js");
describe('Create Folder', function() {
var clickClass = new right_click();
var createClass = new itemCreate();
var editItemClass = new itemEdit();
var ITEM_NAME = "Folder";
var ITEM_TYPE = "folder";
var ITEM_MENU_GLYPH = 'F\nFolder';
var ITEM_GRID_SELECT = 'P\nF\nFolder\n0 Items';
var ITEM_SIDE_SELECT = ">\nF\nFolder"
beforeEach(function() {
browser.ignoreSynchronization = true;
browser.get('http://localhost:1984/warp/');
browser.sleep(2000); // 20 seconds
});
it('should Create new Folder', function(){
browser.sleep(8000);
for(var i=0; i < 1000; i++){
var object = element.all(by.repeater('child in composition')).filter(function (ele){
return ele.getText().then(function(text) {
return text === ">\nF\nMy Items";
});
});
//browser.sleep(1000)
browser.actions().mouseMove(object.get(0)).perform();
browser.actions().click(protractor.Button.RIGHT).perform();
element.all(by.css('.items-holder.grid.abs.ng-scope')).click();
}
browser.pause();
});
});

View File

@ -24,6 +24,6 @@
module.exports = function launch() { module.exports = function launch() {
'use strict'; 'use strict';
browser.ignoreSynchronization = true; browser.ignoreSynchronization = true;
browser.get('http://localhost:1984/'); browser.get('http://localhost:1984/warp');
browser.sleep(2000); // 20 seconds browser.sleep(2000); // 2 seconds
}; };

View File

@ -24,18 +24,25 @@ var RightMenu = (function () {
function RightMenu() { function RightMenu() {
} }
function carrotMyItem(){
var MyItem = ">\nF\nMy Items"
element.all(by.repeater('child in composition')).filter(function (ele){
return ele.getText().then(function(text) {
return text === MyItem;
});
}).all(by.css('.ui-symbol.view-control.ng-binding.ng-scope')).click();
}
//RightMenu Click on Object //RightMenu Click on Object
RightMenu.prototype.delete = function (name, flag) { RightMenu.prototype.delete = function (name, flag) {
if(typeof flag === 'undefined'){ if(typeof flag === 'undefined'){
flag = true; flag = true;
} }
if(flag === true){ if(flag === true){
var carrot = element.all(by.css('.ui-symbol.view-control.ng-binding.ng-scope')).get(0).click(); carrotMyItem();
} }
browser.sleep(1000) browser.sleep(1000)
var object = element.all(by.repeater('child in composition')).filter(function (ele){ var object = element.all(by.repeater('child in composition')).filter(function (ele){
return ele.getText().then(function(text) { return ele.getText().then(function(text) {
//expect(text).toEqual("3");
return text === name; return text === name;
}); });
}); });
@ -43,7 +50,7 @@ var RightMenu = (function () {
browser.actions().mouseMove(object.get(0)).perform(); browser.actions().mouseMove(object.get(0)).perform();
browser.actions().click(protractor.Button.RIGHT).perform(); browser.actions().click(protractor.Button.RIGHT).perform();
browser.sleep(1000) browser.sleep(1000)
var remove = element.all(by.css('.ng-binding')).filter(function (ele){ element.all(by.css('.ng-binding')).filter(function (ele){
return ele.getText().then(function (text) { return ele.getText().then(function (text) {
return text == "Z\nRemove"; return text == "Z\nRemove";
}) })
@ -58,11 +65,10 @@ var RightMenu = (function () {
}); });
}; };
RightMenu.prototype.reset = function (name) { RightMenu.prototype.reset = function (name) {
var carrot = element.all(by.css('.ui-symbol.view-control.ng-binding.ng-scope')).click(); carrotMyItem();
browser.sleep(1000) browser.sleep(1000)
var object = element.all(by.repeater('child in composition')).filter(function (ele){ var object = element.all(by.repeater('child in composition')).filter(function (ele){
return ele.getText().then(function(text) { return ele.getText().then(function(text) {
//expect(text).toEqual("3");
return text === name; return text === name;
}); });
}).click(); }).click();
@ -75,19 +81,19 @@ var RightMenu = (function () {
return text == "r\nRestart at 0"; return text == "r\nRestart at 0";
}) })
}).click(); }).click();
browser.sleep(1000)
}; };
//click '<', true==yes false==no
RightMenu.prototype.select = function(name, flag){ RightMenu.prototype.select = function(name, flag){
if(typeof flag == "undefined"){ if(typeof flag == "undefined"){
flag = true; flag = true;
} }
//click '<', true==yes false==no
if(flag == true){ if(flag == true){
var carrot = element.all(by.css('.ui-symbol.view-control.ng-binding.ng-scope')).click(); carrotMyItem();
} }
browser.sleep(1000) browser.sleep(1000)
return element.all(by.repeater('child in composition')).filter(function (ele){ return element.all(by.repeater('child in composition')).filter(function (ele){
return ele.getText().then(function(text) { return ele.getText().then(function(text) {
// expect(text).toEqual("3");
return text === name; return text === name;
}); });
}); });
@ -96,7 +102,6 @@ var RightMenu = (function () {
RightMenu.prototype.dragDrop = function(name){ RightMenu.prototype.dragDrop = function(name){
var object = element.all(by.repeater('child in composition')).filter(function (ele){ var object = element.all(by.repeater('child in composition')).filter(function (ele){
return ele.getText().then(function(text) { return ele.getText().then(function(text) {
//expect(text).toEqual("3");
return text === name; return text === name;
}); });
}); });

View File

@ -24,33 +24,33 @@
// conf.js // conf.js
exports.config = { exports.config = {
allScriptsTimeout: 500000, allScriptsTimeout: 500000,
defaultTimeoutInterval: 60000, jasmineNodeOpts: {defaultTimeoutInterval: 360000},
seleniumAddress: 'http://localhost:4444/wd/hub', seleniumAddress: 'http://localhost:4444/wd/hub',
//specs: ['StressTest.js'], //specs: ['StressTestCarrot.js'],
specs: [ specs: [
//'create/CreateActivity.js', 'create/CreateActivity.js',
//'delete/DeleteActivity.js', 'delete/DeleteActivity.js',
//'create/CreateActivityMode.js', 'create/CreateActivityMode.js',
//'delete/DeleteActivityMode.js', 'delete/DeleteActivityMode.js',
//'create/CreateActivityMode.js', 'create/CreateActivityMode.js',
//'create/CreateClock.js', 'create/CreateClock.js',
//'delete/DeleteClock.js', 'delete/DeleteClock.js',
'create/CreateDisplay.js', 'create/CreateDisplay.js',
//'delete/DeleteDisplay.js', 'delete/DeleteDisplay.js',
'create/CreateFolder.js', 'create/CreateFolder.js',
//'delete/DeleteFolder.js', 'delete/DeleteFolder.js',
'create/CreateTelemetry.js', 'create/CreateTelemetry.js',
//'delete/DeleteTelemetry.js', 'delete/DeleteTelemetry.js',
//'create/CreateTimeline.js', 'create/CreateTimeline.js',
//'delete/DeleteTimeline.js', 'delete/DeleteTimeline.js',
//'create/CreateTimer.js', 'create/CreateTimer.js',
//'delete/DeleteTimer.js', 'delete/DeleteTimer.js',
'create/CreateWebPage.js', 'create/CreateWebPage.js',
//'delete/DeleteWebPage.js', 'delete/DeleteWebPage.js',
'UI/Fullscreen.js', 'UI/Fullscreen.js',
'create/CreateButton.js', 'create/CreateButton.js',
//"UI/DragDrop.js", "UI/DragDrop.js",
//"UI/NewWindow.js", "UI/NewWindow.js",
'UI/InfoBubble.js' 'UI/InfoBubble.js'
], ],
capabilities: { capabilities: {

View File

@ -63,7 +63,11 @@ describe('Create Timer', function() {
browser.sleep(1000) browser.sleep(1000)
var timer = element(by.css('.value.ng-binding.active')) var timer = element(by.css('.value.ng-binding.active'))
timer.getText().then(function (time) { timer.getText().then(function (time) {
expect(time).toEqual("0D 00:00:01") var timerChecker = false;
if(time == "0D 00:00:01" || time == "0D 00:00:02"){
timerChecker = true;
}
expect(timerChecker).toEqual(true)
}) })
}); });