From 8fa64330ea5718dc5d300b6131216c2e9e99ffb2 Mon Sep 17 00:00:00 2001 From: starmon00 Date: Mon, 29 Aug 2016 19:40:26 -0700 Subject: [PATCH] front_end test cases --- neo/test/resources/README.txt | 36 +++++++++++++++++ neo/test/resources/front-end.js | 72 +++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 neo/test/resources/README.txt create mode 100644 neo/test/resources/front-end.js diff --git a/neo/test/resources/README.txt b/neo/test/resources/README.txt new file mode 100644 index 000000000..79b70b79f --- /dev/null +++ b/neo/test/resources/README.txt @@ -0,0 +1,36 @@ +Must download selenium-webdriver on Node.js Command Prompt by entering + +npm install selenium-webdriver + +For each browser you are testing, you will be required to download a driver and +add it to Enviornmental Variables PATH. The current browsers currently being tested +are Chrome and Firefox. Please make sure to download the latest version of the driver +and also have the browser itself installed on your computer. + +Chrome: +http://chromedriver.storage.googleapis.com/index.html + +Firefox: +https://github.com/mozilla/geckodriver/releases/ + +For more browser drivers or fully detailed instructions on setting up, visit +https://www.npmjs.com/package/selenium-webdriver + +API Doc: http://seleniumhq.github.io/selenium/docs/api/javascript/index.html + +*********************************************************************************************** +To run test: + +On Node.js Command Prompt change directory to neo\test\resources\ +then run + +node front-end.js + +Browsers will open and test will begin. Please wait for test to be completed. + +If you encounter any errors, it is most likely that you are missing a module file. +Simply return to Node.js Command Prompt and install by running + +npm install (missing module) + +*********************************************************************************************** diff --git a/neo/test/resources/front-end.js b/neo/test/resources/front-end.js new file mode 100644 index 000000000..8d91a3a16 --- /dev/null +++ b/neo/test/resources/front-end.js @@ -0,0 +1,72 @@ +//Load modules +var webdriver = require('selenium-webdriver'); + +//Internet Browser Drivers +var chrome = new webdriver.Builder().forBrowser('chrome').build(); +var firefox = new webdriver.Builder().forBrowser('firefox').build(); + +var drivers = [ chrome, firefox]; +var names = ['Chrome', 'FireFox']; + +//Execute Tests +for (i = 0; i < drivers.length; i++){ + console.log('Now Testing for %s \n', names[i]); + drivers[i].get('http://cloudberry.ics.uci.edu'); + Title_Assert(); + Reset_Button_Assert(); + console.log(' '); + +} + + + + +//Test Functions +function Title_Assert() { + var title = drivers[i].getTitle().then( function(title) { + if(title != "Cloudberry") + { + console.log("************************"); + console.log("Title Check......Failed "); + console.log("************************"); + } + else + console.log("Title Check......Cleared"); + }); + +} + +function Reset_Button_Assert() { + var zoomLevel = drivers[i].findElement(webdriver.By.tagName('map')).getAttribute("zoom").then( function(zoomlevel){ + if(zoomlevel != 4) + { + console.log("****************************************"); + console.log('Reset Button ZoomLevel Check......Failed'); + console.log("****************************************"); + } + else + console.log('Reset Button Zoomlevel Check......Cleared'); + }); + + var latCoordinate = drivers[i].findElement(webdriver.By.tagName('map')).getAttribute("lat").then( function(latCoordinate){ + if(latCoordinate != 39.5) + { + console.log("**************************************************"); + console.log('Reset Button Latitude Coordinate Check......Failed'); + console.log("**************************************************"); + } + else + console.log('Reset Button Latitude Coordinate Check......Cleared'); + }); + + var lngCoordinate = drivers[i].findElement(webdriver.By.tagName('map')).getAttribute("lng").then( function(lngCoordinate){ + if(lngCoordinate != -96.35) + { + console.log("**************************************************"); + console.log('Reset Button Longitude Coordinate Check......Failed'); + console.log("**************************************************"); + } + else + console.log('Reset Button Longitude Coordinate Check......Cleared'); + }); +}