!function(){"use strict";module.exports=new function(){var e=require("chai");global.expect=e.expect,global.should=e.should(),global.assert=e.assert,e.use(require("chai-as-promised"));var n,t=require("./Logger.js"),r=protractor.ExpectedConditions,i=require("./dragula.js"),o=require("./drag.js");return{getRandomString:function(){for(var e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",t=0;t<8;t++){var r=Math.floor(Math.random()*e.length);n+=e.substring(r,r+1)}return n},assertInclude:function(e,n,t){var r;try{assert.include(e,n)}catch(e){if(r=e,t)return t(r)}return r},assertEqual:function(e,n,r){var i;try{t.info("Asserting if actual: "+e+" is equal to expected: "+n+"\n"),assert.equal(e,n)}catch(e){i=e,t.info("Error in assertEqual: "+i+"\n"),r&&r(i)}return i},assertTrue:function(e,n){var r;try{assert.isTrue(e)}catch(e){r=e,t.info("Error in assertTrue: "+r+"\n"),n&&n(r)}return r},waitForAngular:function(){try{browser.waitForAngular()}catch(e){console.log("Ignoring Error ",e),t.info("Ignoring Error "+e+"\n")}},isElementPresent:function(e){return browser.wait(r.visibilityOf(e),1e6,"false").then(function(n){return t.info("Found "+e+"!\n"),console.log(n),!0},function(){return console.log("Did not find element"),t.info("Did not find: "+e+"!\n"),!1})},waitForElementToDisappear:function(e){return browser.wait(r.invisibilityOf(e),1e6,"false").then(function(n){return t.info("Element "+e+"disappeared!\n"),console.log(n),!0},function(){return!1})},isElementNotPresent:function(e){return browser.wait(r.not(r.visibilityOf(e)),1e6,"Found Element").then(function(){return t.info("Did not find "+e+"!\n"),!0},function(){return!1})},isElementVisible:function(e){return browser.wait(e.isPresent(),1e6/3).then(function(n){return!0===n?browser.wait(e.isDisplayed(),1e6/3).then(function(e){return e}):n})},elementToBeClickable:function(e){return browser.wait(function(){return e.click().then(function(){return t.info("Clicked on"+e+"!\n"),!0},function(){return t.info(e+" Not Clickable!\n"),!1})},1e6)},getText:function(e){return this.isElementPresent(e).then(function(){return e.getText()})},sendKeys:function(e,n){return this.isElementPresent(e).then(function(){return e.sendKeys(n)})},alertsIsPresent:function(){return browser.wait(r.alertIsPresent(),1e6)},acceptAlert:function(){return browser.switchTo().alert().accept()},dismissAlert:function(){return browser.switchTo().alert().dismiss()},textToBePresentInElement:function(e,n){return browser.wait(r.textToBePresentInElement(e,n),1e6).then(function(){return t.info(n+" is present in "+e+"!\n"),!0},function(){return t.info(n+" is NOT present in "+e+"!\n"),!1})},textToBePresentInElementValue:function(e,n){return browser.wait(r.textToBePresentInElementValue(e,n),1e6).then(function(){return t.info(n+" is present in "+e+"'s value!\n"),!0},function(){return t.info(n+" is NOT present in "+e+"'s value!\n"),!1})},elementToBeSelected:function(e,n){return browser.wait(r.elementToBeSelected(n),1e6).then(function(){return t.info(n+" is selected!\n"),!0},function(){return t.info(n+" is NOT selected!\n"),!1})},titleContains:function(e){return browser.wait(r.titleContains(e),1e6)},titleIs:function(e){return browser.wait(r.titleIs(e),1e6)},setElementManager:function(e){n=e},getElementManager:function(){return n},uploadFile:function(e){var n=path.resolve(__dirname,e),t=$('input[type="file"]');fs.stat(n,function(e,r){null==e?(console.log("File exists"),t.sendKeys(n)):"ENOENT"==e.code?console.error("File does not exist!!!"):console.log("Some other error: ",e.code)})},scrollIntoView:function(e){return this.isElementPresent(e).then(function(){browser.executeScript("arguments[0].scrollIntoView()",e.getWebElement()).then(function(){t.info("Scrolled to "+e+"\n")})})},dragAndDrop:function(e,n){return this.isElementPresent(e).then(function(){e.getAttribute("draggable").then(function(t){null!=t?browser.executeScript(o,e.getWebElement(),n.getWebElement()):browser.executeScript(i,e.getWebElement(),n.getWebElement()).then(function(){browser.actions().mouseMove(n).mouseUp().perform()})})})},getAttribute:function(e,n){return this.isElementPresent(e).then(function(){return e.getAttribute(n)})},getCssValue:function(e,n){return this.isElementPresent(e).then(function(){return e.getCssValue(n)})},geSSOLogin:function(e,n){var t,r;return t=void 0!==e?e:"502641091",r=void 0!==n?n:"Aut0m@ti0n",this.isElementPresent(element(by.id("username"))).then(function(){element(by.id("username")).sendKeys(t),element(by.id("password")).sendKeys(r),element(by.id("password")).sendKeys(protractor.Key.ENTER)})}}}}();