-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
2,651 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** | ||
* Initializes the sticky side bar | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Contains script generated by twitter API | ||
*/ | ||
!function(d, s, id) { | ||
var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' | ||
: 'https'; | ||
if (!d.getElementById(id)) { | ||
js = d.createElement(s); | ||
js.id = id; | ||
js.src = p + '://platform.twitter.com/widgets.js'; | ||
fjs.parentNode.insertBefore(js, fjs); | ||
} | ||
}(document, 'script', 'twitter-wjs'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
(function($) { | ||
$.fn.extend({ | ||
stickyMojo: function(options) { | ||
|
||
// Exit if there are no elements to avoid errors: | ||
if (this.length === 0) { | ||
return this; | ||
} | ||
|
||
var settings = $.extend({ | ||
'footerID': '', | ||
'contentID': '', | ||
'orientation': $(this).css('float'), | ||
'offsetTop': 0 | ||
}, options); | ||
|
||
var sticky = { | ||
'el': $(this), | ||
'stickyLeft': $(settings.contentID).outerWidth() + $(settings.contentID).offset.left, | ||
'stickyTop2': $(this).offset().top, | ||
'stickyHeight': $(this).outerHeight(true), | ||
'contentHeight': $(settings.contentID).outerHeight(true), | ||
'win': $(window), | ||
'breakPoint': $(this).outerWidth(true) + $(settings.contentID).outerWidth(true), | ||
'marg': parseInt($(this).css('margin-top'), 10) | ||
}; | ||
|
||
var errors = checkSettings(); | ||
cacheElements(); | ||
|
||
return this.each(function() { | ||
buildSticky(); | ||
}); | ||
|
||
function buildSticky() { | ||
if (!errors.length) { | ||
sticky.el.css('left', sticky.stickyLeft); | ||
|
||
sticky.win.bind({ | ||
'load': stick, | ||
'scroll': stick, | ||
'resize': function() { | ||
sticky.el.css('left', sticky.stickyLeft); | ||
stick(); | ||
} | ||
}); | ||
} else { | ||
if (console && console.warn) { | ||
console.warn(errors); | ||
} else { | ||
alert(errors); | ||
} | ||
} | ||
} | ||
|
||
// Caches the footer and content elements into jquery objects | ||
function cacheElements() { | ||
settings.footerID = $(settings.footerID); | ||
settings.contentID = $(settings.contentID); | ||
} | ||
|
||
// Calcualtes the limits top and bottom limits for the sidebar | ||
function calculateLimits() { | ||
return { | ||
limit: settings.footerID.offset().top - sticky.stickyHeight, | ||
windowTop: sticky.win.scrollTop(), | ||
stickyTop: sticky.stickyTop2 - sticky.marg | ||
} | ||
} | ||
|
||
// Sets sidebar to fixed position | ||
function setFixedSidebar() { | ||
sticky.el.css({ | ||
position: 'fixed', | ||
top: settings.offsetTop+'px' | ||
}); | ||
} | ||
|
||
// Determines the sidebar orientation and sets margins accordingly | ||
function checkOrientation() { | ||
if (settings.orientation === "left") { | ||
settings.contentID.css('margin-left', sticky.el.outerWidth(true)); | ||
} else { | ||
sticky.el.css('margin-left', settings.contentID.outerWidth(true)); | ||
} | ||
} | ||
|
||
// sets sidebar to a static positioned element | ||
function setStaticSidebar() { | ||
sticky.el.css({ | ||
'position': 'static', | ||
'margin-left': '0px' | ||
}); | ||
settings.contentID.css('margin-left', '0px'); | ||
} | ||
|
||
// initiated to stop the sidebar from intersecting the footer | ||
function setLimitedSidebar(diff) { | ||
sticky.el.css({ | ||
top: diff | ||
}); | ||
} | ||
|
||
//determines whether sidebar should stick and applies appropriate settings to make it stick | ||
function stick() { | ||
var tops = calculateLimits(); | ||
var hitBreakPoint = tops.stickyTop < tops.windowTop + settings.offsetTop && (sticky.win.width() >= sticky.breakPoint); | ||
if (hitBreakPoint) { | ||
setFixedSidebar(); | ||
checkOrientation(); | ||
} else { | ||
setStaticSidebar(); | ||
} | ||
if (tops.limit < tops.windowTop) { | ||
var diff = tops.limit - tops.windowTop; | ||
setLimitedSidebar(diff); | ||
} | ||
} | ||
|
||
// verifies that all settings are correct | ||
function checkSettings() { | ||
var errors = []; | ||
for (var key in settings) { | ||
if (!settings[key]) { | ||
errors.push(settings[key]); | ||
} | ||
} | ||
ieVersion() && errors.push("NO IE 7"); | ||
return errors; | ||
} | ||
|
||
function ieVersion() { | ||
if(document.querySelector) { | ||
return false; | ||
} | ||
else { | ||
return true; | ||
} | ||
} | ||
} | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@CHARSET "UTF-8"; | ||
|
||
#sidebar { | ||
float: left; | ||
width: 150px; | ||
height: 300px; | ||
border: 0px solid #000; | ||
position: fixed; | ||
z-index:1; | ||
margin-top:150px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@CHARSET "UTF-8"; | ||
#sidebar { | ||
width: 120px; | ||
background-color: #ccc; | ||
min-height: 200px; | ||
margin: 10px 0 15px 0; /*controls the cutoff of the top and bottom limitations*/ | ||
padding: 15px 10px; | ||
float: left; /* float right for a right aligned sidebar */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package automation | ||
|
||
import scala.slick.driver.PostgresDriver.simple._ | ||
import org.specs2.mutable.Specification | ||
import play.api.test.WithServer | ||
import play.api.libs.ws.WS | ||
import play.api.test.Helpers._ | ||
import play.api.test.Helpers.await | ||
import play.api.test.TestServer | ||
import play.api.test.WithServer | ||
import utils.Connection | ||
import java.util.concurrent.TimeUnit | ||
import org.openqa.selenium.support.ui.Select | ||
import play.api.test.FakeApplication | ||
import org.openqa.selenium.firefox.FirefoxDriver | ||
import org.openqa.selenium.By | ||
import org.openqa.selenium.WebElement | ||
|
||
class ApprovingUserRequestTest extends Specification { | ||
val port = 19001 | ||
val baseUrl = "http://localhost:19001" | ||
|
||
"Approving a request" in { | ||
running(TestServer(port, FakeApplication(additionalConfiguration = inMemoryDatabase())), HTMLUNIT) { browser => | ||
val driver = new FirefoxDriver | ||
driver.manage().window().maximize() | ||
driver.get(baseUrl + "/login") | ||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS) | ||
driver.findElementById("email").sendKeys("test") | ||
driver.findElementById("password").sendKeys("test") | ||
driver.findElementByCssSelector(".btn.btn-primary").click | ||
driver.findElementById("menuItem").click | ||
driver.findElementById("brandForm").click | ||
driver.findElementById("name").sendKeys("nokia") | ||
driver.findElementByCssSelector(".btn.btn-primary").click | ||
driver.findElementByCssSelector(".panel-title").getText.contains("Brand successfully added") | ||
driver.findElementById("menuItem").click | ||
driver.findElementById("createMobileModel").click | ||
new Select(driver.findElementById("brandName")).selectByVisibleText("nokia") | ||
driver.findElementById("modelName").sendKeys("Asha 200") | ||
driver.findElementByCssSelector(".btn.btn-primary").click | ||
driver.findElementById("stolenPhone").click | ||
driver.findElementById("userName").sendKeys("manish") | ||
new Select(driver.findElementById("brandId")).selectByVisibleText("nokia") | ||
new Select(driver.findElementById("mobileModelId")).selectByVisibleText("Asha 200") | ||
driver.findElementById("email").sendKeys("[email protected]") | ||
driver.findElementById("imeiMeid").sendKeys("123456789012347") | ||
driver.executeScript("""document.getElementById("purchaseDate").value="03/03/2014";""") | ||
driver.findElementById("contactNo").sendKeys("+91 1234567890") | ||
driver.findElementById("description").sendKeys("selenium test desc") | ||
driver.findElementById("fileUpload").sendKeys("/home/knoldus/Pictures/selenium.png") | ||
driver.findElementByCssSelector(".btn.btn-primary").click | ||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS) | ||
driver.findElementById("menuItem").click | ||
driver.findElementById("listOfRequest").click | ||
driver.findElementById("approve").click | ||
driver.findElementByCssSelector("BODY").getText().contains("Mobile has been approved successfully!") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package automation | ||
|
||
import scala.slick.driver.PostgresDriver.simple._ | ||
import org.specs2.mutable.Specification | ||
import play.api.test.WithServer | ||
import play.api.libs.ws.WS | ||
import play.api.test.Helpers._ | ||
import play.api.test.Helpers.await | ||
import play.api.test.TestServer | ||
import play.api.test.WithServer | ||
import utils.Connection | ||
import java.util.concurrent.TimeUnit | ||
import org.openqa.selenium.support.ui.Select | ||
import play.api.test.FakeApplication | ||
import org.openqa.selenium.firefox.FirefoxDriver | ||
import org.openqa.selenium.By | ||
import org.openqa.selenium.WebElement | ||
|
||
class BrandInsertionTest extends Specification { | ||
val port = 19001 | ||
val baseUrl = "http://localhost:19001" | ||
|
||
"Testing Add Mobile Brand" in { | ||
running(TestServer(port), FIREFOX) { browser => | ||
browser.webDriver.manage().window().maximize() | ||
browser.goTo(baseUrl + "/login") | ||
browser.$("#email").text("test") | ||
browser.$("#password").text("test") | ||
browser.$(".btn.btn-primary").click | ||
browser.$("#menuItem").click | ||
browser.$("#brandForm").click | ||
browser.$("#name").text("nokia") | ||
browser.$(".btn.btn-primary").click | ||
browser.$(".alert.alert-dismissable.alert-success").getText() must contain("Brand successfully added") | ||
} | ||
} | ||
} |
Oops, something went wrong.