diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js index a1bc8dc6a..669f13dff 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/editParamsCtrl.js @@ -29,7 +29,7 @@ blueprintName:items.execution.name }; } - + console.log(items); $scope.botName = items.name; $scope.botParams = items.inputFormFields; $scope.botEditParams = {}; @@ -292,6 +292,9 @@ } reqBody.choiceParam = $scope.choiceParam; } + } else if ($scope.botType === 'api') { + reqBody.data = $scope.botEditParams; + reqBody.flowId = items.flowId; } $scope.botExecuteMethod(items.id,reqBody); } else if (type === 'blueprints') { diff --git a/client/cat3/src/partials/sections/dashboard/bots/tabs/editParams.html b/client/cat3/src/partials/sections/dashboard/bots/tabs/editParams.html index 7befe09f6..d4f9931f4 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/tabs/editParams.html +++ b/client/cat3/src/partials/sections/dashboard/bots/tabs/editParams.html @@ -65,7 +65,7 @@
No Matching Blueprint Found in the Database
-
+
diff --git a/server/app/engine/bots/apiExecutor.js b/server/app/engine/bots/apiExecutor.js new file mode 100644 index 000000000..f13868168 --- /dev/null +++ b/server/app/engine/bots/apiExecutor.js @@ -0,0 +1,104 @@ +/* + Copyright [2016] [Relevance Lab] + + 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. + */ + +var logger = require('_pr/logger')(module); +var async = require("async"); +var uuid = require('node-uuid'); +var logsDao = require('_pr/model/dao/logsdao.js'); +var noticeService = require('_pr/services/noticeService.js'); +var auditQueue = require('_pr/config/global-data.js'); +var request = require('request'); +const errorType = 'apiExecutor'; +var apiExecutor = module.exports = {}; + +apiExecutor.execute = function execute(botDetail,reqBody, auditTrail, userName,botHostDetails,callback) { + var actionLogId = uuid.v4(); + var reqBodyObj = { + "inputs": reqBody.data + }; + var botAuditTrailObj = { + botId: botDetail._id, + actionId: actionLogId + } + callback(null, botAuditTrailObj); + var serverUrl = "http://" + botHostDetails.hostIP + ':' + botHostDetails.hostPort; //currently hardcoded; will have to be made dynamic later + var executorUrl = '/bot/' + botDetail.id + '/exec'; + var options = { + url: serverUrl + executorUrl, + headers: { + 'Content-Type': 'application/json', + 'charset': 'utf-8' + }, + json: true, + body: reqBodyObj + }; + + request.post(options, function (err, res, body) { + if(res){ + if (res.statusCode === 200) { + var auditQueueDetails = { + userName: userName, + botId: botDetail.id, + bot_id: botDetail._id, + logRefId: [], + auditId: actionLogId, + instanceLog: '', + instanceIP: '', + auditTrailId: auditTrail._id, + remoteAuditId: res.body.ref, + link: res.body.link, + status: "pending", + serverUrl: serverUrl, + env: "local", + retryCount: 0 + } + auditQueue.setAudit(auditQueueDetails); + return; + } else { + logger.error(err); + var logData = { + botId: botDetail._id, + botRefId: actionLogId, + err: true, + log: "Error in BOT Engine executor:", + timestamp: new Date().getTime(), + } + logsDao.insertLog(logData); + noticeService.updater(actionId,'log',logData); + var resultTaskExecution = { + "actionStatus": 'failed', + "status": 'failed', + "endedOn": new Date().getTime(), + "actionLogId": actionLogId + }; + auditTrailService.updateAuditTrail('BOT', auditTrail._id, resultTaskExecution, function (err, data) { + if (err) { + logger.error("Failed to create or update bots Log: ", err); + } + noticeService.notice(userName, { + title: "API BOT Execution", + body: res.statusCode === 502?"Bot Enginge is not running":"Error in API executor" + }, "error", function (err, data) { + if (err) { + logger.error("Error in Notification Service, ", err); + } + return; + }); + }); + } + } + }) + } diff --git a/server/app/model/bots/1.1/bot.js b/server/app/model/bots/1.1/bot.js index c1b4fd3e1..7b6acc0a1 100644 --- a/server/app/model/bots/1.1/bot.js +++ b/server/app/model/bots/1.1/bot.js @@ -205,6 +205,11 @@ var BotSchema = new Schema ({ required: false, trim: true }, + flowId: { + type: String, + required: false, + trim: true + }, lastExecutionStatus: { type: String, required: false, diff --git a/server/app/services/botService.js b/server/app/services/botService.js index 9569d9a38..8af1adbeb 100644 --- a/server/app/services/botService.js +++ b/server/app/services/botService.js @@ -28,11 +28,12 @@ var scriptExecutor = require('_pr/engine/bots/scriptExecutor.js'); var chefExecutor = require('_pr/engine/bots/chefExecutor.js'); var blueprintExecutor = require('_pr/engine/bots/blueprintExecutor.js'); var jenkinsExecutor = require('_pr/engine/bots/jenkinsExecutor.js'); -var fileIo = require('_pr/lib/utils/fileio'); +var apiExecutor = require('_pr/engine/bots/apiExecutor.js'); var masterUtil = require('_pr/lib/utils/masterUtil.js'); var uuid = require('node-uuid'); var settingService = require('_pr/services/settingsService'); + const fileHound= require('filehound'); const yamlJs= require('yamljs'); const gitHubService = require('_pr/services/gitHubService.js'); @@ -41,85 +42,6 @@ const errorType = 'botService'; var botService = module.exports = {}; -botService.createNew = function createNew(reqBody,callback) { - fileUpload.getReadStreamFileByFileId(reqBody.fileId, function (err, fileDetail) { - if (err) { - logger.error("Error in reading YAML File."); - callback(err, null); - return; - } else { - var fileName = uuid.v4() + '_' + fileDetail.fileName; - var desPath = appConfig.scriptDir + fileName; - fileIo.writeFile(desPath, fileDetail.fileData, false, function (err) { - if (err) { - logger.error("Unable to write file"); - callback(err, null); - return; - } else { - yamlJs.load(desPath, function (result) { - if (result !== null) { - var paramObj = {}; - if (reqBody.type === 'chef') { - paramObj = { - data: { - runlist: reqBody.runlist, - attributes: reqBody.attributes - } - } - } else if (reqBody.type === 'script') { - paramObj = { - scriptId: reqBody.scriptId, - data: reqBody.params - } - } else if (reqBody.type === 'jenkins') { - paramObj = { - jenkinsServerId: reqBody.jenkinsServerId, - jenkinsBuildName: reqBody.jenkinsBuildName, - data: reqBody.params - } - } else { - paramObj = paramObj; - } - var botsObj = { - ymlJson: result, - name: result.name, - id: result.id, - desc: result.desc, - category: reqBody.category, - action: result.action, - execution: result.execution, - type: reqBody.type, - subType: reqBody.subType, - inputFormFields: result.input[0].form, - isParameterized:result.isParameterized?result.isParameterized:false, - outputOptions: result.output, - ymlDocFileId: reqBody.fileId, - orgId: reqBody.orgId, - orgName: reqBody.orgName, - manualExecutionTime: reqBody.standardTime, - params: paramObj, - source: "Catalyst" - } - botDao.createNew(botsObj, function (err, data) { - if (err) { - logger.error(err); - callback(err, null); - removeScriptFile(desPath); - return; - } else { - callback(null, data); - removeScriptFile(desPath); - return; - } - }); - - } - }) - } - }); - } - }); -} botService.updateBotsScheduler = function updateBotsScheduler(botId,botObj,callback) { if(botObj.scheduler && botObj.scheduler !== null && Object.keys(botObj.scheduler).length !== 0 && botObj.isScheduled && botObj.isScheduled === true) { @@ -287,11 +209,11 @@ botService.getBotsList = function getBotsList(botsQuery,actionStatus,serviceNowC callback(err,null); return; } - var resultObj = { - bots : results.botList.bots, - metaData : results.botList.metaData, - botSummary: results.botSummary - } + var resultObj = { + bots : results.botList.bots, + metaData : results.botList.metaData, + botSummary: results.botSummary + } callback(null,resultObj); return; }); @@ -307,7 +229,7 @@ botService.executeBots = function executeBots(botsId,reqBody,userName,executionT function(bots,next){ if(bots.length > 0) { botId = bots[0]._id; - if (reqBody !== null && reqBody !== '' && (bots[0].type === 'script' || bots[0].type === 'chef') && schedulerCallCheck === false) { + if (reqBody !== null && reqBody !== '' && (bots[0].type === 'script' || bots[0].type === 'chef' || bots[0].type === 'api') && schedulerCallCheck === false) { masterUtil.getBotRemoteServerDetailByOrgId(bots[0].orgId, function (err, botServerDetails) { if (err) { logger.error("Error while fetching BOTs Server Details"); @@ -316,7 +238,7 @@ botService.executeBots = function executeBots(botsId,reqBody,userName,executionT } else if (botServerDetails !== null) { botRemoteServerDetails.hostIP = botServerDetails.hostIP; botRemoteServerDetails.hostPort = botServerDetails.hostPort; - encryptedParam(reqBody, next); + next(null,bots); } else { var error = new Error(); error.message = 'BOTs Remote Engine is not configured or not in running mode'; @@ -326,7 +248,7 @@ botService.executeBots = function executeBots(botsId,reqBody,userName,executionT }); } else { - next(null, reqBody); + next(null,bots); } }else{ var error = new Error(); @@ -335,22 +257,6 @@ botService.executeBots = function executeBots(botsId,reqBody,userName,executionT next(error, null); } }, - function(paramObj,next) { - if(schedulerCallCheck === false) { - var botObj = { - params:paramObj - } - if(reqBody.nodeIds){ - botObj.params.nodeIds = reqBody.nodeIds; - } - botDao.updateBotsDetail(botId,botObj, next); - }else{ - next(null,paramObj); - } - }, - function(updateStatus,next) { - botDao.getBotsById(botId, next); - }, function(botDetails,next) { if(botDetails.length > 0){ async.parallel({ @@ -382,18 +288,27 @@ botService.executeBots = function executeBots(botsId,reqBody,userName,executionT }, function(auditTrail,next) { var uuid = require('node-uuid'); - auditTrail.actionId = uuid.v4(); + auditTrail.actionId = uuid.v4(); if (botDetails[0].type === 'script') { - scriptExecutor.execute(botDetails[0], auditTrail, userName, executionType, botRemoteServerDetails, next); - } else if (botDetails[0].type === 'chef') { - chefExecutor.execute(botDetails[0], auditTrail, userName, executionType, botRemoteServerDetails, next); - } else if (botDetails[0].type === 'blueprints') { - reqBody = botDetails[0].params; + scriptExecutor.execute(botDetails[0],reqBody, auditTrail, userName, executionType, botRemoteServerDetails,schedulerCallCheck, next); + }else if (botDetails[0].type === 'chef') { + chefExecutor.execute(botDetails[0],reqBody, auditTrail, userName, executionType, botRemoteServerDetails,schedulerCallCheck, next); + }else if (botDetails[0].type === 'blueprints' || botDetails[0].type === 'blueprint') { + if(schedulerCallCheck === true) { + reqBody = botDetails[0].params; + } blueprintExecutor.execute(botDetails[0].id,auditTrail, reqBody, userName, next); - } else if (botDetails[0].type === 'jenkins') { - reqBody = botDetails[0].params; + }else if (botDetails[0].type === 'jenkins') { + if(schedulerCallCheck === true) { + reqBody = botDetails[0].params; + } jenkinsExecutor.execute(botDetails[0],auditTrail, reqBody, userName, next); - } else { + }else if (botDetails[0].type === 'api') { + if(schedulerCallCheck === true) { + reqBody = botDetails[0].params; + } + apiExecutor.execute(botDetails[0],reqBody,auditTrail, userName,botRemoteServerDetails, next); + }else { var err = new Error('Invalid BOT Type'); err.status = 400; err.msg = 'Invalid BOT Type'; @@ -411,13 +326,35 @@ botService.executeBots = function executeBots(botsId,reqBody,userName,executionT }) }, bots: function (callback) { - if(botDetails[0].type === 'script' || botDetails[0].type === 'chef' || botDetails[0].type === 'jenkins' || botDetails[0].type === 'blueprints') { + if((botDetails[0].type === 'api' || botDetails[0].type === 'script' || botDetails[0].type === 'chef' || botDetails[0].type === 'jenkins' || botDetails[0].type === 'blueprints' || botDetails[0].type === 'blueprint') + && schedulerCallCheck === true) { var botExecutionCount = botDetails[0].executionCount + 1; var botUpdateObj = { executionCount: botExecutionCount, - lastRunTime: new Date().getTime() + lastRunTime: new Date().getTime(), } botDao.updateBotsDetail(botId, botUpdateObj, callback); + } else if((botDetails[0].type === 'api' || botDetails[0].type === 'script' || botDetails[0].type === 'chef' || botDetails[0].type === 'jenkins' || botDetails[0].type === 'blueprints' || botDetails[0].type === 'blueprint') + && schedulerCallCheck === false) { + encryptedParam(reqBody,botDetails[0].inputFormFields,function(err,encryptData){ + if(err){ + var err = new Error('Data encryption is Failed'); + err.status = 400; + err.message = 'Data encryption is Failed'; + callback(err, null); + }else{ + var botExecutionCount = botDetails[0].executionCount + 1; + var botUpdateObj = { + executionCount: botExecutionCount, + lastRunTime: new Date().getTime(), + params:encryptData + } + if(reqBody.nodeIds){ + botUpdateObj.params.nodeIds = reqBody.nodeIds; + } + botDao.updateBotsDetail(botId, botUpdateObj, callback); + } + }); }else{ var err = new Error('Invalid BOT Type'); err.status = 400; @@ -434,7 +371,7 @@ botService.executeBots = function executeBots(botsId,reqBody,userName,executionT }); }else { next(null,botDetails); - } + } } ],function(err,results){ if(err){ @@ -491,7 +428,6 @@ botService.syncSingleBotsWithGitHub = function syncSingleBotsWithGitHub(botId,ca next(err, null); } else { var botsObj = { - ymlJson: result, name: result.name, id: result.id, desc: result.desc, @@ -643,7 +579,6 @@ botService.syncBotsWithGitHub = function syncBotsWithGitHub(gitHubId,callback){ }); }else{ var botsObj={ - ymlJson:result, name:result.name, gitHubId:gitHubDetails.botSync._id, gitHubRepoName:gitHubDetails.botSync.repositoryName, @@ -841,9 +776,10 @@ botService.getParticularBotsHistoryLogs= function getParticularBotsHistoryLogs(b if(bots.length > 0) { var logsDao = require('_pr/model/dao/logsdao.js'); logsDao.getLogsByReferenceId(historyId, timestamp,next); - }else{ + }else{ next({errCode:400, errMsg:"Bots is not exist in DB"},null) - } + } + } ],function(err,results){ if(err){ @@ -885,20 +821,23 @@ botService.updateLastBotExecutionStatus= function updateLastBotExecutionStatus(b } -function encryptedParam(paramDetails, callback) { +function encryptedParam(paramDetails,inputFormDetails, callback) { var cryptoConfig = appConfig.cryptoSettings; var cryptography = new Cryptography(cryptoConfig.algorithm, cryptoConfig.password); var encryptedObj = {}; - if (paramDetails.category === 'script' && paramDetails.data && paramDetails.data !== null) { - Object.keys(paramDetails.data).forEach(function (key) { - var encryptedText = cryptography.encryptText(paramDetails.data[key], cryptoConfig.encryptionEncoding, + if (paramDetails.type === 'script' && paramDetails.data && paramDetails.data !== null) { + inputFormDetails.forEach(function(formField){ + if(formField.type === 'password' || formField.type === 'restricted'){ + var encryptedText = cryptography.encryptText(paramDetails.data[formField.name], cryptoConfig.encryptionEncoding, cryptoConfig.decryptionEncoding); - encryptedObj[key] = encryptedText; - }); - paramDetails.data = encryptedObj; - callback(null, paramDetails); + paramDetails.data[formField.name] = encryptedText; + } + }) + callback(null, paramDetails); + return; }else{ callback(null, paramDetails); + return; } } @@ -1036,15 +975,3 @@ function addYmlFileDetailsForBots(bots,reqData,callback){ } } } - -function removeScriptFile(filePath) { - fileIo.removeFile(filePath, function(err, result) { - if (err) { - logger.error(err); - return; - } else { - logger.debug("Successfully Remove file"); - return - } - }) -} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/.DS_Store b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/.DS_Store new file mode 100644 index 000000000..96a0c6fc4 Binary files /dev/null and b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/.DS_Store differ diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/.kitchen.yml b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/.kitchen.yml new file mode 100644 index 000000000..6b073c8f7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/.kitchen.yml @@ -0,0 +1,16 @@ +--- +driver: + name: vagrant + +provisioner: + name: chef_solo + +platforms: + - name: ubuntu-14.04 + - name: centos-7.1 + +suites: + - name: default + run_list: + - recipe[sensu-client::default] + attributes: diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Berksfile b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Berksfile new file mode 100644 index 000000000..967b9a78b --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Berksfile @@ -0,0 +1,3 @@ +source "https://supermarket.chef.io" + +metadata diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/CHANGELOG.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/CHANGELOG.md new file mode 100644 index 000000000..ce7e226f1 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/CHANGELOG.md @@ -0,0 +1,13 @@ +sensu-client CHANGELOG +====================== + +This file is used to list changes made in each version of the sensu-client cookbook. + +0.1.0 +----- +- [your_name] - Initial release of sensu-client + +- - - +Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. + +The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Gemfile b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Gemfile new file mode 100644 index 000000000..19e399def --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Gemfile @@ -0,0 +1,18 @@ +source 'https://rubygems.org' + +gem 'berkshelf' + +# Uncomment these lines if you want to live on the Edge: +# +# group :development do +# gem "berkshelf", github: "berkshelf/berkshelf" +# gem "vagrant", github: "mitchellh/vagrant", tag: "v1.6.3" +# end +# +# group :plugins do +# gem "vagrant-berkshelf", github: "berkshelf/vagrant-berkshelf" +# gem "vagrant-omnibus", github: "schisamo/vagrant-omnibus" +# end + +gem "test-kitchen" +gem "kitchen-vagrant" diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/README.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/README.md new file mode 100644 index 000000000..7dc8a1f95 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/README.md @@ -0,0 +1,68 @@ +sensu-client Cookbook +===================== +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +Requirements +------------ +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +e.g. +#### packages +- `toaster` - sensu-client needs toaster to brown your bagel. + +Attributes +---------- +TODO: List your cookbook attributes here. + +e.g. +#### sensu-client::default +
+ + + + + + + + + + + + +
KeyTypeDescriptionDefault
['sensu-client']['bacon']Booleanwhether to include bacontrue
+ +Usage +----- +#### sensu-client::default +TODO: Write usage instructions for each cookbook. + +e.g. +Just include `sensu-client` in your node's `run_list`: + +```json +{ + "name":"my_node", + "run_list": [ + "recipe[sensu-client]" + ] +} +``` + +Contributing +------------ +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +License and Authors +------------------- +Authors: TODO: List authors diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Thorfile b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Thorfile new file mode 100644 index 000000000..7a0c0ffb3 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Thorfile @@ -0,0 +1,12 @@ +# encoding: utf-8 + +require 'bundler' +require 'bundler/setup' +require 'berkshelf/thor' + +begin + require "kitchen/thor_tasks" + Kitchen::ThorTasks.new +rescue LoadError + puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"] +end diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Vagrantfile b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Vagrantfile new file mode 100644 index 000000000..f2da4dc9a --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/Vagrantfile @@ -0,0 +1,90 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = '2' + +Vagrant.require_version '>= 1.5.0' + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + config.vm.hostname = 'sensu-client-berkshelf' + + # Set the version of chef to install using the vagrant-omnibus plugin + # NOTE: You will need to install the vagrant-omnibus plugin: + # + # $ vagrant plugin install vagrant-omnibus + # + if Vagrant.has_plugin?("vagrant-omnibus") + config.omnibus.chef_version = 'latest' + end + + # Every Vagrant virtual environment requires a box to build off of. + # If this value is a shorthand to a box in Vagrant Cloud then + # config.vm.box_url doesn't need to be specified. + config.vm.box = 'chef/ubuntu-14.04' + + + # Assign this VM to a host-only network IP, allowing you to access it + # via the IP. Host-only networks can talk to the host machine as well as + # any other machines on the same network, but cannot be accessed (through this + # network interface) by any external networks. + config.vm.network :private_network, type: 'dhcp' + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider :virtualbox do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # The path to the Berksfile to use with Vagrant Berkshelf + # config.berkshelf.berksfile_path = "./Berksfile" + + # Enabling the Berkshelf plugin. To enable this globally, add this configuration + # option to your ~/.vagrant.d/Vagrantfile file + config.berkshelf.enabled = true + + # An array of symbols representing groups of cookbook described in the Vagrantfile + # to exclusively install and copy to Vagrant's shelf. + # config.berkshelf.only = [] + + # An array of symbols representing groups of cookbook described in the Vagrantfile + # to skip installing and copying to Vagrant's shelf. + # config.berkshelf.except = [] + + config.vm.provision :chef_solo do |chef| + chef.json = { + mysql: { + server_root_password: 'rootpass', + server_debian_password: 'debpass', + server_repl_password: 'replpass' + } + } + + chef.run_list = [ + 'recipe[sensu-client::default]' + ] + end +end diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/attributes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/attributes/default.rb new file mode 100644 index 000000000..020f7871f --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/attributes/default.rb @@ -0,0 +1,6 @@ +default['sensu_install']['rabbitmq_host'] = 'sensu.relevancelab.com' +default['sensu_install']['rabbitmq_port'] = '5672' +default['sensu_install']['rabbitmq_username'] = 'sensu' +default['sensu_install']['rabbitmq_password'] = 'sensu' +default['sensu_install']['rabbitmq_vhostname']= '/sensu' +default['sensu_install']['instance-id'] = "i-d3411313" diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/chefignore b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/chefignore new file mode 100644 index 000000000..7be3c6dfa --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/chefignore @@ -0,0 +1 @@ +.kitchen diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/metadata.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/metadata.rb new file mode 100644 index 000000000..d0508fab2 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/metadata.rb @@ -0,0 +1,33 @@ +name 'sensu_install' +maintainer 'YOUR_COMPANY_NAME' +maintainer_email 'YOUR_EMAIL' +license 'All rights reserved' +description 'Installs/Configures sensu-client' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' + +attribute 'sensu_install/rabbitmq_host', + display_name: 'RabbitMQ host IP Address', + description: "RabbitMQ host IP Address", + default: 'sensu.relevancelab.com' + +attribute 'sensu_install/rabbitmq_port', + display_name: 'RabbitMQ Port Number', + description: "RabbitMQ Port Number", + default: 5672 + +attribute 'sensu_install/rabbitmq_username', + display_name: 'RabbitMQ username', + description: "RabbitMQ username", + default: 'sensu' + +attribute 'sensu_install/rabbitmq_password', + display_name: 'RabbitMQ Password', + description: "RabbitMQ Password", + default: 'sensu' + +attribute 'sensu_install/rabbitmq_vhost', + display_name: 'RabbitMQ Vhost name', + description: "RabbitMQ Vhost Name", + default: '/sensu' + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/recipes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/recipes/default.rb new file mode 100644 index 000000000..7674689d9 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/recipes/default.rb @@ -0,0 +1,97 @@ +# +# Cookbook Name:: sensu-client +# Recipe:: default +# +# Copyright 2015, Relevance labe +# Written by Manjunath contact support@Relevancelab.com +# +# All rights reserved - Do Not Redistribute +# + +ruby_block 'instance-details' do + block do + node.default['sensu_install']['instance-id'] = %x[curl http://169.254.169.254/latest/meta-data/instance-id] + node.default['sensu_install']['rabbitmq_host'] = %x[curl http://169.254.169.254/latest/meta-data/local-ipv4] + end +end + +case node['platform'] + + when 'debian', 'ubuntu' + + remote_file '/tmp/sensu_pubkey.gpg' do + source 'http://repos.sensuapp.org/apt/pubkey.gpg' + action :create + notifies :run, 'execute[add_sensu_gpg]', :immediately + end + + + execute "add_sensu_gpg" do + command 'cat /tmp/sensu_pubkey.gpg | apt-key add -' + user "root" + action :nothing + end + + execute "add_repo" do + command 'echo "deb http://repos.sensuapp.org/apt sensu main" > /etc/apt/sources.list.d/sensu.list' + not_if do ::File.exists?('/etc/apt/sources.list.d/sensu.list') end + notifies :run, 'execute[repo_update]', :immediately + end + + execute "repo_update" do + command 'apt-get update' + action :nothing + end + + when 'redhat', 'centos', 'fedora' + file '/etc/yum.repos.d/sensu.repo' do + content '[sensu] +name=sensu-main +baseurl=http://repos.sensuapp.org/yum/el/$releasever/$basearch/ +gpgcheck=0 +enabled=1 +' + action :create + notifies :run, 'execute[yum_update]', :immediately + end + + execute "yum_update" do + command "yum update" + action :nothing + end +end + + +package "Install Sensu client" do + package_name 'sensu' +end + +template '/etc/sensu/conf.d/rabbitmq.json' do + source 'config.json.erb' + mode '0755' + variables( + :rabbitmq_host => node['sensu_install']['rabbitmq_host'], + :rabbitmq_port => node['sensu_install']['rabbitmq_port'], + :rabbitmq_user => node['sensu_install']['rabbitmq_username'], + :rabbitmq_password => node['sensu_install']['rabbitmq_password'], + :rabbitmq_vhost => node['sensu_install']['rabbitmq_vhostname'] + ) +end + +template '/etc/sensu/conf.d/client.json' do + source 'client.json.erb' + mode '0755' + variables( + lazy{ + {:node_name => "#{node['fqdn']}", + :node_ip => "#{node['ipaddress']}", + :sensu_id => "#{node['sensu_install']['instance-id']}"} + } + ) + notifies :restart, 'service[sensu-client]', :immediately +end + +service 'sensu-client' do + action :nothing + supports :status => true, :start => true, :stop => true, :restart => true +end diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/templates/default/client.json.erb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/templates/default/client.json.erb new file mode 100644 index 000000000..1adb95ba7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/templates/default/client.json.erb @@ -0,0 +1,9 @@ +{ + "client": { + "name": "<%= @sensu_id %>", + "address": "<%= @node[:ipaddress] %>", + "subscriptions": [ + "<%= @sensu_id %>","test" + ] + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/templates/default/config.json.erb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/templates/default/config.json.erb new file mode 100644 index 000000000..499d1d6b7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/chef/sensu_install/templates/default/config.json.erb @@ -0,0 +1,9 @@ +{ + "rabbitmq": { + "host": "<%= @rabbitmq_host %>", + "port": <%= @rabbitmq_port %>, + "user": "<%= @rabbitmq_user %>", + "password": "<%= @rabbitmq_password %>", + "vhost": "<%= @rabbitmq_vhost %>" + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/script.js b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Check_BOTs/script.js new file mode 100644 index 000000000..e69de29bb diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Composite_BOTs/script.js b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Composite_BOTs/script.js new file mode 100644 index 000000000..e69de29bb diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/RUN_BOTs/script.js b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/RUN_BOTs/script.js new file mode 100644 index 000000000..e69de29bb diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/disk_usage_remediation_bot/diskUsageRemediation.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/disk_usage_remediation_bot/diskUsageRemediation.py new file mode 100644 index 000000000..ac3d68b06 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/disk_usage_remediation_bot/diskUsageRemediation.py @@ -0,0 +1,51 @@ +import os,sys +import json +# from subprocess import * +# from subprocess import Popen,PIPE,STDOUT,call + +def delete(filepath): + command = "rm " + filepath + result = os.system(command) + return result + +def create_successful_response(status, filepath): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": { + "cleanedUpFile":"%s" + } + }"""%(status, filepath) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s" + } + }"""%(status, description) + return jsonErrorResponse + +try: + findOutput=os.popen('find / -name "*.log" -type f -size +1c -exec du -b {} ";" | sort -rh | head -n1').readlines() + filepath = None + filesize = None + for i in findOutput: + temp = i.split("\t") + filepath = temp[1] + filesize = int(temp[0]) + + result = None + result = delete(filepath) + + if result == 0: + response = create_successful_response(result, filepath) + else : + response = create_error_response(1, "Delete Operation Failed") + print response + exit(0) +except Exception as e: + print "Exception %s" %e + jsonErrorResponse = create_error_response(1, e) + print >>sys.stderr, jsonErrorResponse + exit(1) diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/disk_utility_bot/diskUtility.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/disk_utility_bot/diskUtility.py new file mode 100644 index 000000000..536077c66 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/disk_utility_bot/diskUtility.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +import os, sys +import json + +def get_system_disk_info(): + used_Percentage = os.popen("df -h / | grep -v Filesystem | awk '{print $5}'").readline().strip() + disk = os.statvfs("/") + capacity = disk.f_bsize * disk.f_blocks + available = disk.f_bsize * disk.f_bavail + used = disk.f_bsize * (disk.f_blocks - disk.f_bavail) + return (capacity, used, available, used_Percentage) + +def create_file_size_for_warning (capacity, used, warningPercent): + warningFileSize = warningPercent * capacity + creationFileSize = warningFileSize - used + creationFileSizeKB = int(creationFileSize/1024) + command = "fallocate -l %sK warningFile.log" % creationFileSizeKB + os.system (command) + return (creationFileSize,creationFileSizeKB) + +def create_file_size_for_critical (capacity, used, criticalPercent): + criticalFileSize = criticalPercent * capacity + creationFileSize = criticalFileSize - used + creationFileSizeKB = int(creationFileSize/1024) + command = "fallocate -l %sK criticalFile.log" % creationFileSizeKB + os.system (command) + return (creationFileSize,creationFileSizeKB) + +def create_file_size_for_Complete_Volume(capacity, used, completePercent): + completeVolumeFileSize = completePercent * capacity + creationFileSize = completeVolumeFileSize - used + creationFileSizeKB =int(creationFileSize/1024) + command = "fallocate -l %sK completeVolumeFile.log" % creationFileSizeKB + os.system (command) + +def create_successful_response(status, completeVolumeSize, preUsedSpace, preAvailableSpace, preUsedPercent, postUsedSpace, postAvailableSpace, postUsedPercent): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": { + "completeVolumeSize":"%s", + "preUsedSpace":"%s", + "preFreeSpace":"%s", + "preUsedPercentage":"%s", + "postUsedSpace":"%s", + "postFreeSpace":"%s", + "postUsedPercentage":"%s" + } + }"""%(status, completeVolumeSize, preUsedSpace, preAvailableSpace, preUsedPercent, postUsedSpace, postAvailableSpace, postUsedPercent) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + +try: + + warningPercent=0.88 + criticalPercent=0.96 + completePercent=0.99 + option=sys.argv[1] + + completeVolumeSize, preUsedSpace, preAvailableSpace, preUsedPercent = get_system_disk_info() + + if option =='warning': + create_file_size_for_warning (completeVolumeSize, preUsedSpace, warningPercent) + elif option=='critical': + create_file_size_for_critical(completeVolumeSize, preUsedSpace, criticalPercent) + else: + create_file_size_for_Complete_Volume(completeVolumeSize, preUsedSpace, completePercent) + + completeVolumeSize, postUsedSpace, postAvailableSpace, postUsedPercent = get_system_disk_info() + + jsonSuccessResponse = create_successful_response(0, completeVolumeSize, preUsedSpace, preAvailableSpace, preUsedPercent, postUsedSpace, postAvailableSpace, postUsedPercent) + print jsonSuccessResponse + exit(0) + +except Exception as e: + jsonErrorResponse = create_error_response(1, e) + print >> sys.stderr, jsonErrorResponse + exit(1) \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/extract_host_ip_bot/extract_host_ip.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/extract_host_ip_bot/extract_host_ip.sh new file mode 100755 index 000000000..e20d43caa --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/extract_host_ip_bot/extract_host_ip.sh @@ -0,0 +1,2 @@ +apt-get install -y host +host $1 > /var/log/extract_host_ip_bot.log diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/https_scanner_bot/httpsScanner.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/https_scanner_bot/httpsScanner.sh new file mode 100644 index 000000000..b2e1dc9ff --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/https_scanner_bot/httpsScanner.sh @@ -0,0 +1,29 @@ +#!/bin/bash +##### Checking for number of arguments +if [ "$#" -ne 1 ]; then + echo "Illegal number of parameters" + exit 1 +fi +##### Installing nmap +sudo apt-get install nmap +##### to get the open port +nmap -v -p443 -PN $1 | grep open | grep Discovered > /tmp/httpsReport.txt +####to filter out the IP from nmapreport + sed -e 's/\//g' /tmp/httpsReport.txt > test3 +rm -rf test2 + sed -e 's/\//g' test3 > test4 +rm -rf test3 + sed -e 's/\//g' test4 > test5 +rm -rf test4 + sed -e 's/\<443\>//g' test5 > test6 +rm -rf test5 + +## removin special chaaracter /##### +sed 's/\///' test6 > test7 +rm -rf test6 + sed -e 's/\//g' test7 > test8 +rm -rf test7 +sed -e 's/\//g' test8 > test9 +rm -rf test8 +sed 's/[[:blank:]]//g' test9 > /tmp/httpsReport.txt +rm -rf test9 diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/nginx_remediation_bot/nginxRemediation.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/nginx_remediation_bot/nginxRemediation.py new file mode 100644 index 000000000..28e836379 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/nginx_remediation_bot/nginxRemediation.py @@ -0,0 +1,59 @@ +import os,sys +import json +from subprocess import * + +def startService(startCommand): + startFileObject = os.popen(startCommand) + output = startFileObject.read() + exitCode = startFileObject.close() + return output, exitCode + +def statusService(statusCommand): + statusFileObject = os.popen(statusCommand) + output = statusFileObject.read() + exitCode = statusFileObject.close() + return output.strip(), exitCode + +def create_successful_response(status, result): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": + { + "statusDescription":"%s" + } + }"""%(status, result) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + + +try: + startCommand = 'sudo service nginx start' + output, exitCode = startService(startCommand) + + if (exitCode) != None : + jsonErrorResponse = create_error_response(1, "check command") + print jsonErrorResponse + exit(1) + + statusCommand = 'sudo service nginx status' + output, exitCode = statusService(statusCommand) + + if (exitCode) != None : + jsonErrorResponse = create_error_response(1, "check command") + print jsonErrorResponse + + else : + jsonSuccessResponse = create_successful_response(0, output) + print jsonSuccessResponse + +except Exception as e: + jsonErrorResponse = create_error_response(1, e) + print >>sys.stderr, jsonErrorResponse + exit(1) \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/pagerduty_create_bot/pagerdutyCreate.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/pagerduty_create_bot/pagerdutyCreate.py new file mode 100644 index 000000000..d961e002f --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/pagerduty_create_bot/pagerdutyCreate.py @@ -0,0 +1,73 @@ +import sys +import requests +from requests.auth import HTTPBasicAuth + +def create_pagerdutyIncident(service_key, event_type, description, client, client_url, details): + + url = "https://events.pagerduty.com/generic/2010-04-15/create_event.json" + headers = { + 'content-type': "application/json" + } + + payload = """ + { + "service_key": "%s", + "event_type": "%s", + "description": "%s", + "client": "%s", + "client_url": "%s", + "details": "%s", + "contexts":[ + { + "type": "link", + "href": "http://telemetry.rlcatalyst.com/#/events", + "text": "View Events on Telemetry" + },{ + "type": "link", + "href": "http://telemetry.rlcatalyst.com/#/sae/", + "text": "View SAE on Telemetry" + } + ] + } + """ %(service_key, event_type, description, client, client_url, details) + + response = requests.request("POST", url, data=payload, headers=headers) + return response + +def create_successful_response(status, result): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": %s + }"""%(status, result) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + +try: + service_key = sys.argv[1] + event_type = sys.argv[2] + description = sys.argv[3] + client = sys.argv[4] + client_url = sys.argv[5] + details = sys.argv[6] + + result = create_pagerdutyIncident(service_key, event_type, description, client, client_url, details) + if result.status_code not in [201,200]: + jsonErrorResponse = create_error_response(1, result.text) + print >> sys.stderr, jsonErrorResponse + exit(1) + + jsonSuccessResponse = create_successful_response(0, result.text) + print jsonSuccessResponse + exit(0) + +except Exception as e: + jsonErrorResponse = create_error_response(1, e) + print >> sys.stderr, jsonErrorResponse + exit(1) diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/pagerduty_update_bot/pagerdutyUpdate.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/pagerduty_update_bot/pagerdutyUpdate.py new file mode 100644 index 000000000..d36e76db2 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/pagerduty_update_bot/pagerdutyUpdate.py @@ -0,0 +1,83 @@ + +import sys +import json +import requests +from requests.auth import HTTPBasicAuth + +def get_pagerdutyIncident(apiToken, incidentKey): + + url = "https://api.pagerduty.com/incidents" + + headers = { + "Authorization": "Token token="+ apiToken + } + + payload = { + "incident_key": incidentKey + } + response = requests.request("GET", url, params=payload, headers=headers) + return response + +def update_pagerdutyIncident(apiToken, emailId, pagerDutyId, status): + + url = "https://api.pagerduty.com/incidents" + "/" + pagerDutyId + + headers = { + "Content-Type": "application/json", + "From": emailId, + "Authorization": "Token token="+ apiToken + } + + payload = { + "incident": { + "type": "incident_reference", + "status": status + } + } + + response = requests.request("PUT", url, json=payload, headers=headers) + return response + +def create_successful_response(status, result): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": %s + }"""%(status, result) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + +try: + apiToken = sys.argv[1] + emailId = sys.argv[2] + incidentKey = sys.argv[3] + status = sys.argv[4] + + resultGet = get_pagerdutyIncident(apiToken, incidentKey) + if resultGet.status_code not in [201,200]: + jsonErrorResponse = create_error_response(1, resultGet.text) + print >> sys.stderr, jsonErrorResponse + exit(1) + + resultDictionary = json.loads(resultGet.text) + pagerDutyId = resultDictionary['incidents'][0]['id'] + resultPut = update_pagerdutyIncident(apiToken, emailId, pagerDutyId, status) + if resultPut.status_code not in [201,200]: + jsonErrorResponse = create_error_response(1, resultPut.text) + print >> sys.stderr, jsonErrorResponse + exit(1) + + jsonSuccessResponse = create_successful_response(0, resultPut.text) + print jsonSuccessResponse + exit(0) + +except Exception as e: + jsonErrorResponse = create_error_response(1, e) + print >> sys.stderr, jsonErrorResponse + exit(1) diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/servicenow_create_bot/servicenowCreate.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/servicenow_create_bot/servicenowCreate.py new file mode 100644 index 000000000..74d06f5ab --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/servicenow_create_bot/servicenowCreate.py @@ -0,0 +1,55 @@ +import sys +import requests +from requests.auth import HTTPBasicAuth + +def create_servicenowTicket(hostname, username, password, short_description, comments, x_14768_catalyst_first_name, + x_14768_catalyst_last_name, category, x_14768_catalyst_password, location): + url = hostname + "/api/now/v1/table/incident" + headers = { + 'content-type': "application/json" + } + payload = """{"short_description": '%s', "comments":'%s',"x_14768_catalyst_first_name":'%s', + "x_14768_catalyst_last_name":'%s',"category": '%s', + "x_14768_catalyst_password": "%s","location":'%s'}"""%(short_description, comments, x_14768_catalyst_first_name, + x_14768_catalyst_last_name, category, x_14768_catalyst_password, location) + response = requests.request("POST", url, data=payload,auth=HTTPBasicAuth(username, password), headers=headers) + return response + +def create_successful_response(status, result): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": %s + }"""%(status, result) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + +try: + hostname = sys.argv[1] + username = sys.argv[2] + password = sys.argv[3] + short_description = sys.argv[4] + comments = sys.argv[5] + x_14768_catalyst_first_name = sys.argv[6] + x_14768_catalyst_last_name = sys.argv[7] + category = sys.argv[8] + x_14768_catalyst_password = sys.argv[9] + location = sys.argv[10] + + result = create_servicenowTicket(hostname, username, password, short_description, comments, x_14768_catalyst_first_name, + x_14768_catalyst_last_name, category, x_14768_catalyst_password, location) + + jsonSuccessResponse = create_successful_response(0, result.text) + print jsonSuccessResponse + exit(0) + +except Exception as e: + jsonErrorResponse = create_error_response(1, e) + print >> sys.stderr, jsonErrorResponse + exit(1) diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/servicenow_update_bot/servicenowUpdate.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/servicenow_update_bot/servicenowUpdate.py new file mode 100644 index 000000000..b80d5f990 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/servicenow_update_bot/servicenowUpdate.py @@ -0,0 +1,60 @@ +import sys +import requests +from requests.auth import HTTPBasicAuth + +def update_servicenowTicket(hostname, username, password, incidentId, short_description, comments, x_14768_catalyst_first_name, + x_14768_catalyst_last_name, category, x_14768_catalyst_password, location, state): + url = hostname + "/api/now/v1/table/incident/" + incidentId + querystring = {"sysparm_exclude_ref_link":"true"} + headers = { + 'content-type': "application/json" + } + payload = """{ + "short_description": "%s", "comments":"%s","x_14768_catalyst_first_name":"%s", + "x_14768_catalyst_last_name":"%s","category": "%s", + "x_14768_catalyst_password": "%s","location":'%s',"state":"%s"}"""%(short_description, comments, x_14768_catalyst_first_name, + x_14768_catalyst_last_name, category, x_14768_catalyst_password, location, state) + response = requests.request("PUT", url, data=payload, auth=HTTPBasicAuth(username, password), headers=headers, params=querystring) + return response + +def create_successful_response(status, result): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": %s + }"""%(status, result) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + +try: + hostname = sys.argv[1] + username = sys.argv[2] + password = sys.argv[3] + incidentId = sys.argv[4] + short_description = sys.argv[5] + comments = sys.argv[6] + x_14768_catalyst_first_name = sys.argv[7] + x_14768_catalyst_last_name = sys.argv[8] + category = sys.argv[9] + x_14768_catalyst_password = sys.argv[10] + location = sys.argv[11] + state = sys.argv[12] + + + result = update_servicenowTicket(hostname, username, password, incidentId, short_description, comments, x_14768_catalyst_first_name, + x_14768_catalyst_last_name, category, x_14768_catalyst_password, location, state) + + jsonSuccessResponse = create_successful_response(0, result.text) + print jsonSuccessResponse + exit(0) + +except Exception as e: + jsonErrorResponse = create_error_response(1, e) + print >> sys.stderr, jsonErrorResponse + exit(1) diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/slack_notification_bot/slackNotification.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/slack_notification_bot/slackNotification.py new file mode 100644 index 000000000..5c40c0bbe --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/slack_notification_bot/slackNotification.py @@ -0,0 +1,59 @@ +import requests +import sys + + +def slack_notification(hostname, channelName, msg, userName,icon,color): + url = hostname + attachmentTemplates = """ [ + { + "color": "%s", + "title": "%s", + "footer": "RLCatalyst-Telemetry", + "footer_icon": "https://platform.slack-edge.com/img/default_application_icon.png" + } + ] + """ + icon = '%s' + color = '%s' + attachment = attachmentTemplates%(color,msg) + payload = 'payload={"attachments": %s, "channel": "%s", "username": "%s", "iconEmoji": "%s"}'%(attachment, channelName, userName, icon) + headers = { + 'content-type': "application/x-www-form-urlencoded" + } + response = requests.request("POST", url, data=payload, headers=headers) + return response.text , response.status_code + +def create_successful_response(status, result): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": { + "slackOutput":"%s" + } + }"""%(status, result) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + +try: + hostname = sys.argv[1] + channelName = sys.argv[2] + msg = sys.argv[3] + userName = sys.argv[4] + icon = sys.argv[5] + color = sys.argv[6] + + result = slack_notification(hostname, channelName, msg, userName, icon, color) + jsonSuccessResponse = create_successful_response(0, result) + print jsonSuccessResponse + exit(0) + +except Exception as e: + jsonErrorResponse = create_error_response(1, e) + print >> sys.stderr, jsonErrorResponse + exit(1) diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/ssl_check_bot/sslcheck.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/ssl_check_bot/sslcheck.py new file mode 100644 index 000000000..42bfd3ae3 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/ssl_check_bot/sslcheck.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +# +# Check Expiration Date of SSL certificates +# +# Koen Van Impe +# +# Uses the file ceds.checks as input ; one entry per line, format : +# +# ceds.checks : www.google.com:443 +# imap.mydomain.tld:993 +# + +from OpenSSL import SSL +import socket, datetime +import smtplib +from email.mime.text import MIMEText +import json +import sys + +def ssl_check_expiration(host, port): + response = "" + try: + context = SSL.Context(SSL.SSLv23_METHOD) + sock = SSL.Connection(context, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) + + try: + sock.connect( (str(host) , int(port)) ) + sock.send("\x00") # Send empty to trigger response + get_peer_cert=sock.get_peer_certificate() + sock.close() + + exp_date = datetime.datetime.strptime(get_peer_cert.get_notAfter(),'%Y%m%d%H%M%SZ') + days_to_expire = int((exp_date - cur_date).days) + + if days_to_expire < 0: + response = response + "\n %s EXPIRED" % (host) + elif alert_days > days_to_expire: + response = response + "\n %s expires in %s days " % (host, days_to_expire) + # print response + + return days_to_expire + except: + response = response + "\n Unable to connect to %s " % (host) + return None + except SSL.Error,e: + return None + +def create_successful_response(status, totalNumberOfCertificates, result): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": { + "totalNumberOfCertificates":"%s", + "machine":%s + } + } + """%(status, totalNumberOfCertificates, result) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + +try: + servers_to_check = sys.argv[1] + servers = open( servers_to_check, "r") + cur_date = datetime.datetime.utcnow() + cert_tested = 0 + data = [] + + for line in servers: + host = line.strip() + port = 443 + days_to_expire = ssl_check_expiration(host, port) + cert_tested = cert_tested + 1 + + dictionary = {} + dictionary["hostname"] = host + dictionary["daysRemaining"] = days_to_expire + data.append(dictionary) + + jsonSuccessResponse = create_successful_response(0, cert_tested, json.dumps(data)) + print jsonSuccessResponse + exit(0) +except Exception as e: + jsonErrorResponse = create_error_response(1, "Error Obtaining Certificate Expiry Details") + print >> sys.stderr, jsonErrorResponse + exit(1) diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/value_predictor_bot/valuePredictor.py b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/value_predictor_bot/valuePredictor.py new file mode 100644 index 000000000..ef10f2798 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Script_BOTs/value_predictor_bot/valuePredictor.py @@ -0,0 +1,68 @@ +from __future__ import division +import sys +import math + +def getResourceUsage(pCents, threshold): + + if ( threshold > 100 ) : + print "Threshold value should be between 1 to 100" + + period = len(pCents) + initialValue = int(pCents[0]) + presentValue = int(pCents[len(pCents) - 1]) + growthRate, usageLimit = growthPredictor(initialValue, presentValue, period, threshold) + return growthRate, usageLimit + + +def growthPredictor(initialValue, presentValue, period, threshold): + growthRate = math.pow((presentValue/initialValue), (1/period)) - 1.00 + usageLimit = math.log((threshold/initialValue), 10.00)/math.log((1 + growthRate), 10.00) + return growthRate, round(usageLimit) + + +def extractdata(filepath): + + f = open(filepath, 'r') + pCents = [] + for line in f: + k, v = line.strip().split(',') + pCents.append(v) + f.close() + + return pCents + +def create_successful_response(status, growthRate, threshold, timeUnit, expectedTime): + jsonSuccessResponse = """{ + "status": "%s", + "outputParameters": { + "growthRate":%s, + "threshold":%s, + "timeUnit":"%s", + "expectedTime":%s + } + }"""%(status, growthRate, threshold, timeUnit, expectedTime) + return jsonSuccessResponse + +def create_error_response(status, description): + jsonErrorResponse = """{ + "status": "%s", + "errorParameters": { + "description":"%s"} + }"""%(status, description) + return jsonErrorResponse + +try: + + filepath = sys.argv[1] + threshold = int(sys.argv[2]) + timeUnit = sys.argv[3] + pCents = extractdata(filepath) + growthRate, usageLimit = getResourceUsage(pCents, threshold) + jsonSuccessResponse = create_successful_response(0, growthRate, threshold, timeUnit, usageLimit) + print jsonSuccessResponse + exit(0) + +except Exception as e: + jsonErrorResponse = create_error_response(1, e) + print >> sys.stderr, jsonErrorResponse + exit(1) \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/CHANGELOG.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/CHANGELOG.md new file mode 100644 index 000000000..dc5c9d394 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/CHANGELOG.md @@ -0,0 +1,11 @@ +# ad_user_creation CHANGELOG + +This file is used to list changes made in each version of the ad_user_creation cookbook. + +## 0.1.0 +- [your_name] - Initial release of ad_user_creation + +- - - +Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. + +The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/README.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/README.md new file mode 100644 index 000000000..8c3cd81eb --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/README.md @@ -0,0 +1,80 @@ +# ad_user_creation Cookbook + +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +## Requirements + +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +e.g. +### Platforms + +- SandwichOS + +### Chef + +- Chef 12.0 or later + +### Cookbooks + +- `toaster` - ad_user_creation needs toaster to brown your bagel. + +## Attributes + +TODO: List your cookbook attributes here. + +e.g. +### ad_user_creation::default + + + + + + + + + + + + + + +
KeyTypeDescriptionDefault
['ad_user_creation']['bacon']Booleanwhether to include bacontrue
+ +## Usage + +### ad_user_creation::default + +TODO: Write usage instructions for each cookbook. + +e.g. +Just include `ad_user_creation` in your node's `run_list`: + +```json +{ + "name":"my_node", + "run_list": [ + "recipe[ad_user_creation]" + ] +} +``` + +## Contributing + +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +## License and Authors + +Authors: TODO: List authors + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/attributes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/attributes/default.rb new file mode 100644 index 000000000..b2f590ce8 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/attributes/default.rb @@ -0,0 +1,4 @@ +default[:ad_user_creation][:name]=nil #FirstName +default[:ad_user_creation][:surname]=nil #LastName +default[:ad_user_creation][:password]=nil #Password which required one special character and one number +default[:ad_user_creation][:domain_name]=nil #domain name \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/attributes/path.json b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/attributes/path.json new file mode 100644 index 000000000..23bf4582b --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/attributes/path.json @@ -0,0 +1,45 @@ +// { +// "name":"somenode", +// "override_attributes": +// { +// "activeDir": +// { +// "name":"xyz" +// } +// }, +// "override_attributes": +// { +// "activeDir": +// { +// "surname":"abc" +// } +// }, +// "override_attributes": +// { +// "activeDir": +// { +// "password":"password@123" +// } +// }, +// "override_attributes": +// { +// "activeDir": +// { +// "domain_name":"myown.com" +// } +// } +// } +// =========== + +'{ + "override_attributes": + { + "ad_user_creation": {"activeDir":[{"name":"xyz"}, + {"surname": "abc"}, + {"password": "password@123"}, + {"domain_name": "myown.com"}] + } + }, + "run_list": + ["recipe[ad_user_creation]"] +}' \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/metadata.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/metadata.rb new file mode 100644 index 000000000..92c06e3c5 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/metadata.rb @@ -0,0 +1,27 @@ +name 'ad_user_creation' +maintainer 'YOUR_COMPANY_NAME' +maintainer_email 'YOUR_EMAIL' +license 'All rights reserved' +description 'Installs/Configures ad_user_creation' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' + +attribute 'ad_user_creation/name', + display_name: 'First Name', + description: "User's first name", + default: nil + +attribute 'ad_user_creation/surname', + display_name: 'Sur Name', + description: "User's first name", + default: nil + +attribute 'ad_user_creation/password', + display_name: 'User Password', + description: "Password which required one special character and one number", + default: nil + +attribute 'ad_user_creation/domain_name', + display_name: 'Domain Name', + description: "Domain Name", + default: nil \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/recipes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/recipes/default.rb new file mode 100644 index 000000000..eb17c61b9 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserCreation/recipes/default.rb @@ -0,0 +1,29 @@ +# +# Cookbook Name:: ad_user_creation +# Recipe:: default +# +# Copyright 2016, YOUR_COMPANY_NAME +# +# All rights reserved - Do Not Redistribute +# +puts "Printing out the attributes starts" +puts node[:ad_user_creation][:name] +puts node[:ad_user_creation][:surname] +puts node[:ad_user_creation][:domain_name] +puts node[:ad_user_creation][:password] +puts "Printing out the attributes ends" + +name = "#{node[:ad_user_creation][:name]}" +samName = name[0,2] + "#{node[:ad_user_creation][:surname]}" +prinicipalName= samName + "@"+ "#{node[:ad_user_creation][:domain_name]}" + +if name.empty? || samName.empty? || prinicipalName.empty? || node[:ad_user_creation][:password].empty? + #Chef::Application.fatal!("Please Provide the Name, Surname, password & domain name",123) + Chef::Log.info("Please Provide the Name, Surname, password & domain name") +else +powershell_script 'user' do + code <<-EOH + New-ADUser -UserPrincipalName "#{prinicipalName}" -Name "#{node[:ad_user_creation][:name]}" -GivenName "#{node[:ad_user_creation][:name]}" -Surname "#{node[:ad_user_creation][:surname]}" -SamAccountName "#{samName}" -AccountPassword (ConvertTo-SecureString "#{node[:ad_user_creation][:password]}" -AsPlainText -force) -Enabled $True -PasswordNeverExpires $True -PassThru + EOH +end +end \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/CHANGELOG.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/CHANGELOG.md new file mode 100644 index 000000000..bb81cf8f7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/CHANGELOG.md @@ -0,0 +1,11 @@ +# ad_user_deletion CHANGELOG + +This file is used to list changes made in each version of the ad_user_deletion cookbook. + +## 0.1.0 +- [your_name] - Initial release of ad_user_deletion + +- - - +Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. + +The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/README.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/README.md new file mode 100644 index 000000000..3c819d30d --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/README.md @@ -0,0 +1,80 @@ +# ad_user_deletion Cookbook + +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +## Requirements + +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +e.g. +### Platforms + +- SandwichOS + +### Chef + +- Chef 12.0 or later + +### Cookbooks + +- `toaster` - ad_user_deletion needs toaster to brown your bagel. + +## Attributes + +TODO: List your cookbook attributes here. + +e.g. +### ad_user_deletion::default + + + + + + + + + + + + + + +
KeyTypeDescriptionDefault
['ad_user_deletion']['bacon']Booleanwhether to include bacontrue
+ +## Usage + +### ad_user_deletion::default + +TODO: Write usage instructions for each cookbook. + +e.g. +Just include `ad_user_deletion` in your node's `run_list`: + +```json +{ + "name":"my_node", + "run_list": [ + "recipe[ad_user_deletion]" + ] +} +``` + +## Contributing + +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +## License and Authors + +Authors: TODO: List authors + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/attributes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/attributes/default.rb new file mode 100644 index 000000000..989390988 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/attributes/default.rb @@ -0,0 +1,2 @@ +default[:ad_user_deletion][:name]=nil #FirstName +default[:ad_user_deletion][:surname]=nil #LastName \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/metadata.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/metadata.rb new file mode 100644 index 000000000..cdc685597 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/metadata.rb @@ -0,0 +1,18 @@ +name 'ad_user_deletion' +maintainer 'YOUR_COMPANY_NAME' +maintainer_email 'YOUR_EMAIL' +license 'All rights reserved' +description 'Installs/Configures ad_user_deletion' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' + +attribute 'ad_user_deletion/name', + display_name: 'First Name', + description: "User's first name", + default: nil + +attribute 'ad_user_deletion/surname', + display_name: 'Sur Name', + description: "User's Sur name", + default: nil + \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/recipes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/recipes/default.rb new file mode 100644 index 000000000..3089ac178 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/AD_UserDeletion/recipes/default.rb @@ -0,0 +1,20 @@ +# +# Cookbook Name:: ad_user_deletion +# Recipe:: default +# +# Copyright 2016, YOUR_COMPANY_NAME +# +# All rights reserved - Do Not Redistribute +# +name = "#{node[:ad_user_deletion][:name]}" +samName = name[0,2] + "#{node[:ad_user_deletion][:surname]}" + +if name.empty? || samName.empty? + Chef::Log.info("Please provide Name & surname") +else +powershell_script 'password reset' do + code <<-EOH + Remove-ADUser -Identity #{samName} -Confirm:$false + EOH +end +end \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/CHANGELOG.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/CHANGELOG.md new file mode 100644 index 000000000..67eef0eea --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/CHANGELOG.md @@ -0,0 +1,11 @@ +# opendj_user_creation CHANGELOG + +This file is used to list changes made in each version of the opendj_user_creation cookbook. + +## 0.1.0 +- [your_name] - Initial release of opendj_user_creation + +- - - +Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. + +The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/README.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/README.md new file mode 100644 index 000000000..2797116a9 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/README.md @@ -0,0 +1,80 @@ +# opendj_user_creation Cookbook + +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +## Requirements + +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +e.g. +### Platforms + +- SandwichOS + +### Chef + +- Chef 12.0 or later + +### Cookbooks + +- `toaster` - opendj_user_creation needs toaster to brown your bagel. + +## Attributes + +TODO: List your cookbook attributes here. + +e.g. +### opendj_user_creation::default + + + + + + + + + + + + + + +
KeyTypeDescriptionDefault
['opendj_user_creation']['bacon']Booleanwhether to include bacontrue
+ +## Usage + +### opendj_user_creation::default + +TODO: Write usage instructions for each cookbook. + +e.g. +Just include `opendj_user_creation` in your node's `run_list`: + +```json +{ + "name":"my_node", + "run_list": [ + "recipe[opendj_user_creation]" + ] +} +``` + +## Contributing + +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +## License and Authors + +Authors: TODO: List authors + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/attributes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/attributes/default.rb new file mode 100644 index 000000000..6cad10b0e --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/attributes/default.rb @@ -0,0 +1,10 @@ +default[:opendj_user_creation][:firstname] = 'vimal' +default[:opendj_user_creation][:lastname] = 'kumar' +default[:opendj_user_creation][:domain] = 'catalyst' +default[:opendj_user_creation][:group] = 'people' +default[:opendj_user_creation][:password] = 'kaushik' +default[:opendj_user_creation][:emailid] = 'vimalkumar.mishra@relevancelab.com' + +default[:opendj_user_creation][:port] = 389 +default[:opendj_user_creation][:loginName] = 'Directory Manager' +default[:opendj_user_creation][:loginPassword] = 'kaushik' diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/metadata.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/metadata.rb new file mode 100644 index 000000000..0e93166ad --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/metadata.rb @@ -0,0 +1,50 @@ +name 'opendj_user_creation' +maintainer 'YOUR_COMPANY_NAME' +maintainer_email 'YOUR_EMAIL' +license 'All rights reserved' +description 'Installs/Configures opendj_user_creation' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' + +attribute 'opendj_user_creation/firstname', + :display_name => 'First Name', + :description => 'First Name for OpenDJ' + +attribute 'opendj_user_creation/lastname', + :display_name => 'Last Name', + :description => 'Last Name for OpenDJ' + +attribute 'opendj_user_creation/domain', + :display_name => 'Domain Name', + :description => 'Domain Name in OpenDJ', + :default => 'RLIndia' + +attribute 'opendj_user_creation/group', + :display_name => 'Group Name', + :description => 'Specific the Group to add in OpenDJ', + :default => 'people' + +attribute 'opendj_user_creation/password', + :display_name => 'New Passsword', + :description => 'Passsword for the user', + :default => 'password' + +attribute 'opendj_user_creation/emailid', + :display_name => 'Email ID', + :description => 'Email ID for the user' + +attribute 'opendj_user_creation/port', + :display_name => 'Port Number', + :description => 'Port Number of OpenDJ', + :default => '389' + +attribute 'opendj_user_creation/loginName', + :display_name => 'Login Name', + :description => 'Login Name for OpenDJ', + :default => 'Directory Manager' + +attribute 'opendj_user_creation/loginPassword', + :display_name => 'Login Passsword', + :description => 'Login Passsword for OpenDJ', + :default => 'kaushik' + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/recipes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/recipes/default.rb new file mode 100644 index 000000000..151f7f92d --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/recipes/default.rb @@ -0,0 +1,42 @@ +# +# Cookbook Name:: opendj_user_creation +# Recipe:: default +# +# Copyright 2016, YOUR_COMPANY_NAME +# +# All rights reserved - Do Not Redistribute +# +uname = 0 +if node[:opendj_user_creation][:firstname].length > 3 + if node[:opendj_user_creation][:lastname].length > 3 + uname = node[:opendj_user_creation][:firstname][0,3] + node[:opendj_user_creation][:lastname][0,3] + else + uname = node[:opendj_user_creation][:firstname][0,3] + node[:opendj_user_creation][:lastname] + end +else + if node[:opendj_user_creation][:lastname].length > 3 + uname = node[:opendj_user_creation][:firstname] + node[:opendj_user_creation][:lastname][0,3] + else + uname = node[:opendj_user_creation][:firstname] + node[:opendj_user_creation][:lastname] + end +end + + # id = uname+'@'+node[:opendj_user_creation][:domain]+'.com' + +template '/tmp/new.ldif' do + source 'new.erb' + mode '0777' + variables(:firstname => node[:opendj_user_creation][:firstname], :lastname => node[:opendj_user_creation][:lastname], :group => node[:opendj_user_creation][:group], :domain => node[:opendj_user_creation][:domain],:password => node[:opendj_user_creation][:password], :unqiname => uname, :emailid => node[:opendj_user_creation][:emailid]) + #notifies :run, 'execute[slapadd]', :immediately +end + +# execute 'slapadd' do +# command " /tmp/run.log < /opt/opendj/bin/ldapmodify --hostname kaushik.com --port #{node[:opendj_user_creation][:port]} --bindDN 'cn=#{node[:opendj_user_creation][:loginName]}' -w #{node[:opendj_user_creation][:loginPassword]} --defaultAdd --filename /tmp/new.ldif" +# end + +ruby_block 'reload_client_config' do + block do + `/opt/opendj/bin/ldapmodify --port #{node[:opendj_user_creation][:port]} --bindDN 'cn=#{node[:opendj_user_creation][:loginName]}' -w #{node[:opendj_user_creation][:loginPassword]} -f /tmp/new.ldif` + end + action :run +end \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/templates/default/new.erb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/templates/default/new.erb new file mode 100644 index 000000000..3e7a5ad36 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserCreation/templates/default/new.erb @@ -0,0 +1,13 @@ +dn: uid=<%= @unqiname %>,ou=<%= @group %>,dc=<%= @domain %>,dc=com +objectClass: top +objectClass: inetOrgPerson +objectClass: organizationalPerson +objectClass: person +mail: <%= @emailid %> +sn: <%= @lastname %> +cn: <%= @unqiname %> +givenName: <%= @firstname %> +uid: <%= @unqiname %> +userPassword: <%= @password %> + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/CHANGELOG.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/CHANGELOG.md new file mode 100644 index 000000000..16f7695cf --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/CHANGELOG.md @@ -0,0 +1,11 @@ +# opendj_user_deletion CHANGELOG + +This file is used to list changes made in each version of the opendj_user_deletion cookbook. + +## 0.1.0 +- [your_name] - Initial release of opendj_user_deletion + +- - - +Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown. + +The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown. diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/README.md b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/README.md new file mode 100644 index 000000000..d8e5ebb13 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/README.md @@ -0,0 +1,80 @@ +# opendj_user_deletion Cookbook + +TODO: Enter the cookbook description here. + +e.g. +This cookbook makes your favorite breakfast sandwich. + +## Requirements + +TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc. + +e.g. +### Platforms + +- SandwichOS + +### Chef + +- Chef 12.0 or later + +### Cookbooks + +- `toaster` - opendj_user_deletion needs toaster to brown your bagel. + +## Attributes + +TODO: List your cookbook attributes here. + +e.g. +### opendj_user_deletion::default + + + + + + + + + + + + + + +
KeyTypeDescriptionDefault
['opendj_user_deletion']['bacon']Booleanwhether to include bacontrue
+ +## Usage + +### opendj_user_deletion::default + +TODO: Write usage instructions for each cookbook. + +e.g. +Just include `opendj_user_deletion` in your node's `run_list`: + +```json +{ + "name":"my_node", + "run_list": [ + "recipe[opendj_user_deletion]" + ] +} +``` + +## Contributing + +TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section. + +e.g. +1. Fork the repository on Github +2. Create a named feature branch (like `add_component_x`) +3. Write your change +4. Write tests for your change (if applicable) +5. Run the tests, ensuring they all pass +6. Submit a Pull Request using Github + +## License and Authors + +Authors: TODO: List authors + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/attributes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/attributes/default.rb new file mode 100644 index 000000000..465f453a1 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/attributes/default.rb @@ -0,0 +1,5 @@ +default[:opendj_user_deletion][:email_id] = 'vimalkumar.mishra@relevancelab.com' +default[:opendj_user_deletion][:username] = 'Directory Manager' +default[:opendj_user_deletion][:password] = 'kaushik' +default[:opendj_user_deletion][:baseDN] = 'dc=catalyst,dc=com' +default[:opendj_user_deletion][:port] = 389 diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/metadata.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/metadata.rb new file mode 100644 index 000000000..95bbfd927 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/metadata.rb @@ -0,0 +1,31 @@ +name 'opendj_user_deletion' +maintainer 'YOUR_COMPANY_NAME' +maintainer_email 'YOUR_EMAIL' +license 'All rights reserved' +description 'Installs/Configures opendj_user_deletion' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' + +attribute 'opendj_user_deletion/email_id', + :display_name => 'Email ID', + :description => 'Email ID for the user' + +attribute 'opendj_user_deletion/username', + :display_name => 'Login Name', + :description => 'Login Name for OpenDJ', + :default => 'Directory Manager' + +attribute 'opendj_user_deletion/password', + :display_name => 'Login Passsword', + :description => 'Login Passsword for OpenDJ', + :default => 'kaushik' + +attribute 'opendj_user_deletion/baseDN', + :display_name => 'Domain Name', + :description => 'Provide the baseDN', + :default => 'dc=RLIndia,dc=com' + +attribute 'opendj_user_deletion/port', + :display_name => 'Port Number', + :description => 'Port Number of OpenDJ', + :default => '389' diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/recipes/default.rb b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/recipes/default.rb new file mode 100644 index 000000000..2b297c678 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/cookbooks/LDAP_UserDeletion/recipes/default.rb @@ -0,0 +1,23 @@ +# +# Cookbook Name:: opendj_user_deletion +# Recipe:: default +# +# Copyright 2016, YOUR_COMPANY_NAME +# +# All rights reserved - Do Not Redistribute +# +details = `/opt/opendj/bin/ldapsearch --port "#{node[:opendj_user_deletion][:port]}" --baseDN "#{node[:opendj_user_deletion][:baseDN]}" "(mail="#{node[:opendj_user_deletion][:email_id]}")"` + +puts details +puts details.class + +authID = details.split("\n") +uid = authID[0].split(":") +puts authID[0] +puts uid[1] + +# puts "`/opt/opendj/bin/ldappasswordmodify --authzID '\"#{authID[0]}\"' --newPassword '#{node[:opendj_user_deletion][:newpassword]}' --port \"#{node[:opendj_user_deletion][:port]}\" --bindDN \"cn=\"#{node[:opendj_user_deletion][:username]}\"\" --bindPassword \"#{node[:opendj_user_deletion][:password]}\"`" + +logs=`/opt/opendj/bin/ldapdelete --port "#{node[:opendj_user_deletion][:port]}" --bindDN 'cn=#{node[:opendj_user_deletion][:username]}' --bindPassword "#{node[:opendj_user_deletion][:password]}" --noPropertiesFile '#{uid[1]}'` + +puts logs diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script.js b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script.js new file mode 100644 index 000000000..e69de29bb diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/AWS_CLI.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/AWS_CLI.sh new file mode 100755 index 000000000..8cc4d2583 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/AWS_CLI.sh @@ -0,0 +1,8 @@ +#! /bin/bash + +cd /tmp +curl -O https://bootstrap.pypa.io/get-pip.py +sudo python2.7 get-pip.py +sudo pip install awscli +sudo pip install awscli --ignore-installed six +sudo pip install --upgrade awscli diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/AWS_alert.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/AWS_alert.sh new file mode 100755 index 000000000..db0700f6e --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/AWS_alert.sh @@ -0,0 +1,85 @@ +#! /bin/bash +# AWS_alert.sh AWS_access_key AWS_secret_key email_id +ackey=$1 +sckey=$2 +mailid=$3 + +#Installation of AWS CLI +cd /tmp +curl -O https://bootstrap.pypa.io/get-pip.py +sudo python2.7 get-pip.py +sudo pip install awscli +sudo pip install awscli --ignore-installed six +sudo pip install --upgrade awscli +rm -rf get-pip.py + +# Adding Creditionals for AWS CLI +mkdir ~/.aws +cd ~/.aws +echo "[default] +aws_access_key_id=$ackey +aws_secret_access_key=$sckey" >> credentials +echo "[default] +region=us-west-2 +output=text" >> config + +# Adding the Mail Template +echo 'Hi, + +PFA is running list of Non-Production instance in AWS Account. + +Thanks, +Catalyst Bot' > /tmp/detail.txt + +# List of region in AWS Account +region=('ap-south-1' 'eu-west-1' 'ap-northeast-2' 'ap-northeast-1' 'sa-east-1' 'ap-southeast-1' 'ap-southeast-2' 'eu-central-1' 'us-east-1' 'us-east-2' 'us-west-1' 'us-west-2' ); + +for i in "${region[@]}" +do + aws ec2 describe-instances --region "$i" --filters "Name=instance-state-name,Values=running" --query 'Reservations[].Instances[].[Tags[?Key==`Environment` && Value!=`Production`].Value,PrivateIpAddress,InstanceId,Placement.AvailabilityZone]' --output text >> /tmp/instance.xlsx | sed -i '/Non-Production/d' /tmp/instance.xlsx | sed -i '/QA/d' /tmp/instance.xlsx +done + +# Installation of ssmtp server +sudo apt-get update +sudo apt-get install ssmtp + + +# ssmtp template folder +sudo echo '# Config file for sSMTP sendmail + +# The person who gets all mail for userids < 1000 +# Make this empty to disable rewriting. +#root=postmaster +root=catalystservicebot@gmail.com + +# The place where the mail goes. The actual machine name is required no +# MX records are consulted. Commonly mailhosts are named mail.domain.com +#mailhub=mail +mailhub=smtp.gmail.com:587 + +AuthUser=catalystservicebot@gmail.com +AuthPass=catalyst@1234 +UseTLS=YES +UseSTARTTLS=YES + +# Where will the mail seem to come from? +#rewriteDomain= +rewriteDomain=gmail.com + +# The full hostname +#hostname=MyMediaServer.home +hostname=localhost + +# Are users allowed to set their own From: address? +# YES - Allow the user to specify their own From: address +# NO - Use the system generated From: address +FromLineOverride=YES' > /etc/ssmtp/ssmtp.conf + +sudo echo 'root:catalystservicebot@gmail.com:smtp.gmail.com:587' >> /etc/ssmtp/revaliases +sudo apt-get install mpack + +# Sending of the email +mpack -s 'Active list of Non-Production instances' /tmp/instance.xlsx -d /tmp/detail.txt $mailid + +# Deletion of the xlsx file +rm -rf /tmp/instance.xlsx diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Cat_Host_IPAddress.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Cat_Host_IPAddress.sh new file mode 100644 index 000000000..08342c733 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Cat_Host_IPAddress.sh @@ -0,0 +1 @@ +host $1 diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Cat_User_Creation.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Cat_User_Creation.sh new file mode 100755 index 000000000..ab7886f43 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Cat_User_Creation.sh @@ -0,0 +1,36 @@ +#!/bin/bash +#./Cat_User_Creation.sh catalyst_url catalyst_login_user_name catalyst_login_user_pass new_catalyst_user_name_toCreate new_catalyst_user_email_toCreate new_catalyst_user_pass_toCreate new_catalyst_user_role_toCreate +#./Cat_User_Creation.sh https://neocatalyst.rlcatalyst.com superadmin superadmin@123 jonny jonny@gmail pass@123 Consumer + +# Catalyst Initializations +cat_url=$1 +cat_user_name=$2 +cat_user_pass=$3 + +#echo $cat_url +#echo $cat_user_name +#echo $cat_user_pass + +# New Catalyst User Initializations +new_user=$4 +new_user_email=$5 +new_user_pass=$6 +new_user_role=$7 + +# Case condition to get role_id +case "$new_user_role" in + "Admin") new_user_role_id="61" + ;; + "Designer") new_user_role_id="62" + ;; + "Consumer") new_user_role_id="63" + ;; +esac + +# To get the Catalyst login Auth-Token +token=`curl -i -X POST -H "Content-Type: application/json" -H "Accept: application/json" $cat_url/auth/signin -d '{"username":"'"$cat_user_name"'","pass":"'"$cat_user_pass"'","authType":"token"}'| grep token | awk -F":" '{print $2}'|sed 's/\}//g'| sed 's/"//g'` + +#echo $token + +# User creation API +curl -i -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "x-catalyst-auth: $token" $cat_url/d4dMasters/savemasterjsonrownew/7/null/all -d '{"loginname":"'"$new_user"'","email":"'"$new_user_email"'","password":"'"$new_user_pass"'","cnfPassword":"'"$new_user_pass"'","userrolename":"'"$new_user_role"'","userrolename_rowid":"'"$new_user_role_id"'","orgname":"","orgname_rowid":"","teamname":"RL_DEV","teamname_rowid":"7df4b243-2902-48db-a118-f07975331c56"}' diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Meta_bot_Cat_user_creation.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Meta_bot_Cat_user_creation.sh new file mode 100755 index 000000000..aa07699b4 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/Meta_bot_Cat_user_creation.sh @@ -0,0 +1,63 @@ +#!/bin/bash +#./Cat_User_Creation.sh catalyst_url catalyst_login_user_name catalyst_login_user_pass new_catalyst_user_name_toCreate new_catalyst_user_email_toCreate new_catalyst_user_pass_toCreate new_catalyst_user_role_toCreate Slack_BOT_Name Slack_BOT_icon +#./Cat_User_Creation.sh https://neocatalyst.rlcatalyst.com superadmin superadmin@123 jonny jonny@gmail pass@123 Consumer Alert-BOT :bell: + +# Catalyst Initializations +cat_url=$1 +cat_user_name=$2 +cat_user_pass=$3 + +#echo $cat_url +#echo $cat_user_name +#echo $cat_user_pass + +# New Catalyst User Initializations +new_user=$4 +new_user_email=$5 +new_user_pass=$6 +new_user_role=$7 + +# Case condition to get role_id +case "$new_user_role" in + "Admin") new_user_role_id="61" + ;; + "Designer") new_user_role_id="62" + ;; + "Consumer") new_user_role_id="63" + ;; +esac + +# This to show that bot has started in slack + +webhook_url=T0FJN09DZ/B0J0BQN6R/TkffVKJuSkATi7tyiPLLYZFI +channel_name="catalyst_alert" +msg="User Creation BOT for $cat_url has been started for a new user $new_user." + +if [ "$8" == "" ] +then + bot_name='Alert-BOT' +else + bot_name=$8 +fi + +if [ "$9" == "" ] +then + icon=':bell:' +else + icon=$9 +fi +# This Script that post the message in slack +curl -X POST --data-urlencode 'payload={"text": "'"$msg"'", "channel": "#'"$channel_name"'", "username": "'"$bot_name"'", "icon_emoji": "'"$icon"'"}' https://hooks.slack.com/services/$webhook_url + +# To get the Catalyst login Auth-Token +token=`curl -i -X POST -H "Content-Type: application/json" -H "Accept: application/json" $cat_url/auth/signin -d '{"username":"'"$cat_user_name"'","pass":"'"$cat_user_pass"'","authType":"token"}'| grep token | awk -F":" '{print $2}'|sed 's/\}//g'| sed 's/"//g'` + +#echo $token + +# User creation API +curl -i -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "x-catalyst-auth: $token" $cat_url/d4dMasters/savemasterjsonrownew/7/null/all -d '{"loginname":"'"$new_user"'","email":"'"$new_user_email"'","password":"'"$new_user_pass"'","cnfPassword":"'"$new_user_pass"'","userrolename":"'"$new_user_role"'","userrolename_rowid":"'"$new_user_role_id"'","orgname":"","orgname_rowid":"","teamname":"RL_DEV","teamname_rowid":"7df4b243-2902-48db-a118-f07975331c56"}' +# Re-initiliaztion of slack bot +msg="User $new_user is created in $cat_url" + +# This the command to post the slack message +curl -X POST --data-urlencode 'payload={"text": "'"$msg"'", "channel": "#'"$channel_name"'", "username": "'"$bot_name"'", "icon_emoji": "'"$icon"'"}' https://hooks.slack.com/services/$webhook_url diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/packer_AMI_script.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/packer_AMI_script.sh new file mode 100755 index 000000000..a817ef326 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/packer_AMI_script.sh @@ -0,0 +1,60 @@ +#! /bin/bash +# packer_AMI_script.sh release_number 'access_key_of_aws_account' 'secret_key_of_awsaccount' + + +# Intialization of parameters +rlno=$1 +accesskey=$2 +secretkey=$3 +#echo $rlno +#echo $accesskey +#echo $secretkey + + +#Installation of packer +#To get the Architure type +arch=`uname -m` +#Based on Arch download the packer script +if [ ""$arch"" == 'x86_64' ] +then + download='https://releases.hashicorp.com/packer/0.12.0/packer_0.12.0_linux_amd64.zip' +else + download='https://releases.hashicorp.com/packer/0.12.0/packer_0.12.0_linux_386.zip' +fi +#Downloading the packer zip file +wget $download +#Installing the unzip package +sudo apt-get install -y unzip +#Getting the package name +filename=`echo $download | sed 's#.*/##'` +echo $filename +#Unzipping the packer download +unzip $filename +#Copying the packer runnable file to /usr/bin +cp packer /usr/bin/ +#removing the packer and zip folder +rm -rf packer $filename + + +# Cloning of the repo +#changing the directory to root +cd /root/ +#Installing git +sudo apt-get install -y git +#Doing a git clone of the catalyst packing repository +git clone https://catalyst-engg:catalyst_123@github.com/RLIndia/catalystpackaging.git +#Changing into the AWS AMI folder +cd catalystpackaging/RLCatalystImage +# Replacing to lastest release +sed -i -e "s/3.1.0/$rlno/g" rlcatalyst.sh +# Replacing the access key to required access key +sed -i -e "0,/XXXXXXX/s/XXXXXXX/$2/" rlcatalyst.json +# Replacing the secret key to require secret key +sed -i -e "s/XXXXXXX/$3/g" rlcatalyst.json +# Replacing the AMI Name to AMI name with release number +sed -i -e "s/3.3.1/$rlno/g" rlcatalyst.json + + +# Running of packer +# To build the AMI from packer script +sudo packer build rlcatalyst.json diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/packer_Docker_image.sh b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/packer_Docker_image.sh new file mode 100755 index 000000000..a2b8eec69 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/Task_BOTs/script/packer_Docker_image.sh @@ -0,0 +1,83 @@ +#! /bin/bash +# packer_Docker_script.sh release_number 'docker_account_username' 'docker_account_password' 'docker_account_registered_email' + + +#Initialization of script +rlno=$1 +dcusername=$2 +dcpassword=$3 +dcemail=$4 +#Packer Installation +#To get the Architure type +arch=`uname -m` +#Based on Arch download the packer script +if [ ""$arch"" == 'x86_64' ] +then + download='https://releases.hashicorp.com/packer/0.12.0/packer_0.12.0_linux_amd64.zip' +else + download='https://releases.hashicorp.com/packer/0.12.0/packer_0.12.0_linux_amd64.zip' +fi +#Downloading the packer zip file +wget $download +#Installing the unzip package +sudo apt-get install -y unzip +#Getting the package name +filename=`echo $download | sed 's#.*/##'` +echo $filename +#Unzipping the packer download +unzip $filename +#Copying the packer runnable file to /usr/bin +sudo cp packer /usr/bin/ +#removing the packer and zip folder +rm -rf packer $filename + + +#Docker Installation +sudo apt-get update -y +sudo apt-get install -y apt-transport-https ca-certificates +#Adding new GPG key +sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D +#To check for the release ubuntu release number +lsbno=`lsb_release -rs` +case ""$lsbno"" in + "12.04") download="deb https://apt.dockerproject.org/repo ubuntu-precise main" + ;; + "14.04") download="deb https://apt.dockerproject.org/repo ubuntu-trusty main" + ;; + "15.10") download="deb https://apt.dockerproject.org/repo ubuntu-wily main" + ;; + "16.04") download="deb https://apt.dockerproject.org/repo ubuntu-wily main" + ;; +esac +echo $download | sudo tee /etc/apt/sources.list.d/docker.list +sudo apt-get update -y +sudo apt-get install -y linux-image-generic-lts-trusty +sudo apt-get install -y docker-engine + +# To login to docker account +sudo docker login --username="$2" --password="$3" --email="$4" + + +# Cloning of the Repo +# Change of directory +sudo cd /opt/ +# Installing git +sudo apt-get install -y git +# Doing a git clone of the catalyst packing repository +git clone https://catalyst-engg:catalyst_123@github.com/RLIndia/catalystpackaging.git +# Changing into the AWS AMI folder +cd catalystpackaging/DockerRLCatalyst +# Replacing to lastest release +sed -i -e "s/3.4.0/$rlno/g" rlcatalyst.sh +# Replacing the tag Name +sed -i -e "s/3.4.2/$rlno/g" rlcatalyst.json + + +# Running Packer +# To build docker image using packer +sudo packer build rlcatalyst.json + +# To upload image +sudo docker push relevancelab/rlcatalyst:$rlno + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/Test Results - Feature__EmailLoginAndLogout.html b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/Test Results - Feature__EmailLoginAndLogout.html new file mode 100644 index 000000000..f4c67f34a --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/Test Results - Feature__EmailLoginAndLogout.html @@ -0,0 +1,664 @@ + + + + +Test Results — Feature: EmailLoginAndLogout + + + + + + + + + +
+ +
+
    +
  • + +
    3 m 27 s
    +
    Feature: Login and Logout of Mail Application
    +
      +
    • + +
      3 m 27 s
      +
      Scenario Outline: Login and Logout of Mail Application
      +
        +
      • + +
        3 m 27 s
        +
        Examples:
        +
          +
        • + +
          1 m 38 s
          +
          Scenario: Line: 10
          +
            +
          • + +
            1 m 38 s
            +
            passedGiven I Login to catalyst using "https://www.gmail.com" and "servicedesk@relevancelab.com" and "#64J&uV%L1"access credentials
            +
          • +
          • + +
            0 ms
            +
            passedThen I logged out of application successfully
            +
          • +
          +
        • +
        • + +
          1 m 50 s
          +
          Scenario: Line: 11
          +
            +
          • + +
            1 m 50 s
            +
            failedGiven I Login to catalyst using "https://login.yahoo.com/" and "bjohn287@yahoo.com" and "1234%asd"access credentials
            +
              +
            • +junit.framework.AssertionFailedError: Unable to locate element: {"method":"xpath","selector":"//*[@id='uh-logo']"}
              Command duration or timeout: 24.81 seconds
              For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
              Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
              System info: host: 'RLE0372', ip: '192.168.152.125', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_91'
              Driver info: org.openqa.selenium.firefox.FirefoxDriver
              Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
              Session ID: a86e5ec8-215c-4e0c-9199-83f77639c2e6
              *** Element info: {Using=xpath, value=//*[@id='uh-logo']}
              at junit.framework.Assert.fail(Assert.java:57)
              at junit.framework.TestCase.fail(TestCase.java:227)
              at com.rl.qa.views.LoginViews.clickYahooLoginButton(LoginViews.java:121)
              at com.rl.qa.steps.LoginSteps.iLoginToCatalystUsingAndAndAccessCredentials(LoginSteps.java:271)
              at ✽.Given I Login to catalyst using "https://login.yahoo.com/" and "bjohn287@yahoo.com" and "1234%asd"access credentials(D:/qaautomationlibrary/Mail/src/test/resources/mailApplication/EmailLoginAndLogout.feature:4)
              +
            • +
            +
          • +
          • + +
            0 ms
            +
            ignoredThen I logged out of application successfully
            +
              +
            • +Skipped step
              +
            • +
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/catalyst-Test.iml b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/catalyst-Test.iml new file mode 100755 index 000000000..07eab5865 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/catalyst-Test.iml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/desktop.ini b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/desktop.ini new file mode 100755 index 000000000..d957fd188 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/lib/JSErrorCollector-0.6.jar b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/lib/JSErrorCollector-0.6.jar new file mode 100755 index 000000000..a3b159bd0 Binary files /dev/null and b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/lib/JSErrorCollector-0.6.jar differ diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/org/junit/runner/annotations.xml b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/org/junit/runner/annotations.xml new file mode 100755 index 000000000..aa891a031 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/org/junit/runner/annotations.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/pom.xml b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/pom.xml new file mode 100755 index 000000000..5fd13964d --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/pom.xml @@ -0,0 +1,277 @@ + + + 4.0.0 + + com.rl.qa + catalyst-Test + 1.0-SNAPSHOT + + catalystTest + + + test + + + REMOTE_CHROME + + https://gmail.com/ + + + + + + + + Admin2 + pass@123 + http://127.0.0.1:7777/wd/hub + Selenium-T.262 + + + + + + package + + + ${project.basedir}/src/main/resources + true + + chromedriver + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + + UTF-8 + + + + + + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.5 + + + true + + + + + net.masterthought + maven-cucumber-reporting + 0.0.7 + + + execution + verify + + generate + + + cucumber-jvm-example + target/cucumber-html-reports + target/cucumber.json + false + true + true + + + + + + + + + org.apache.maven.plugins + maven-site-plugin + 3.3 + + + + + + + 2.53.1 + 1.1.6 + 4.11 + + + + + org.seleniumhq.selenium + htmlunit-driver + 2.20 + + + + org.seleniumhq.selenium + selenium-java + ${selenium.version} + + + xerces + xercesImpl + + + xml-apis + xml-apis + + + + + org.seleniumhq.selenium + selenium-firefox-driver + ${selenium.version} + + + commons-io + commons-io + + + + + org.seleniumhq.selenium + selenium-ie-driver + ${selenium.version} + + + org.seleniumhq.selenium + selenium-chrome-driver + ${selenium.version} + + + + xml-apis + xml-apis + 1.4.01 + + + org.bluestemsoftware.open.maven.tparty + xerces-impl + 2.9.0 + + + + + info.cukes + cucumber-core + ${cucumber.version} + + + info.cukes + cucumber-java + ${cucumber.version} + + + info.cukes + cucumber-junit + ${cucumber.version} + + + + + net.masterthought + maven-cucumber-reporting + 0.0.7 + + + net.masterthought + cucumber-reporting + 0.0.23 + + + commons-io + commons-io + + + + + + org.glassfish + javax.json + 1.0.4 + + + + com.google.guava + guava + 17.0 + + + + junit + junit + ${junit.version} + + + net.sf.jtidy + jtidy + r938 + + + + com.pojosontheweb + monte-repack + 1.0 + + + + org.slf4j + slf4j-api + 1.6.1 + + + org.slf4j + slf4j-log4j12 + 1.6.1 + + + org.apache.poi + poi-scratchpad + 3.12 + + + org.apache.poi + poi-ooxml-schemas + 3.12 + + + org.apache.poi + poi-ooxml + 3.12 + + + + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/FileUtilities.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/FileUtilities.java new file mode 100755 index 000000000..289a78e6d --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/FileUtilities.java @@ -0,0 +1,155 @@ +package com.rl.qa; + +////////////////////////////////////////////////////////////////////////////// +//(c)2014 Lucernex, Inc. +//Author: Toan Dang +//$Revision: $ +////////////////////////////////////////////////////////////////////////////// + +import org.apache.commons.io.comparator.LastModifiedFileComparator; +import org.apache.commons.io.filefilter.WildcardFileFilter; +import org.junit.rules.ErrorCollector; + +import java.io.*; +import java.util.Arrays; + +public class FileUtilities { + public ErrorCollector collector = new ErrorCollector(); + + public FileUtilities() { + } + + /** + * Returns the current working directory which is generally the root of the + * LxSelenium project when executing a JUnit testcase via maven or IntelliJ. + */ + public static File getCWD() { + return new File(System.getProperty("user.dir")); + } + + /** + * Returns the specified file as expected to be in the LxSelenium/Data folder. + * + * @param filename - filename (no directory just the filename) + */ + public static String getDataFile(String filename) throws IOException { + File dataDir = new File(getCWD(), "Data"); + + if (!dataDir.exists()) { + String msg = String.format("Required directory '%s' not found!", dataDir.getAbsolutePath()); + + throw new IllegalStateException(msg); + } + + return (new File(dataDir, filename)).getCanonicalPath(); + } + + /** + * Returns LxSelenium/Data/ImportDataFiles folder. + */ + public static String getImportDataFilesDir() throws IOException { + File dataDir = new File(getCWD(), "Data"); + + if (!dataDir.exists()) { + String msg = String.format("Required directory '%s' not found!", dataDir.getAbsolutePath()); + + throw new IllegalStateException(msg); + } + + return (new File(dataDir, "ImportDataFiles")).getCanonicalPath(); + } + + public void createDirectory(String createDirectoryName) { + + File dir = new File(createDirectoryName); + if (!dir.exists()) + dir.mkdir(); + } + + public void deleteDirectory(String deleteDirectoryName) throws FileNotFoundException, IOException { + File deleteDirectory = new File(deleteDirectoryName); + deleteDirectory.delete(); + + } + + /* + * Copy to new file to different location and delete the original file + * + */ + public static void copyFile(File fromFileInfo,File toFileInfo) throws FileNotFoundException, IOException + { + FileInputStream input = null; + FileOutputStream output = null; + try { + output = new FileOutputStream( toFileInfo ); // open this first, in case we don't have write permissions + input = new FileInputStream( fromFileInfo ); + + final int NO_OFFSET = 0; + int length; + byte[] buffer = new byte[10240]; + while ((length = input.read(buffer)) != -1) { + output.write(buffer, NO_OFFSET, length); + } + + } finally { + if (input != null) { + input.close(); + } + if (output != null) { + output.flush(); + output.getFD().sync(); + output.close(); + + } + + } + + } + + + public String getFileNamebysubString(String curDirectoryName, String containString) throws FileNotFoundException, IOException { + String retString = ""; + + for (File file : listFiles(curDirectoryName)) { + + if (file.isFile()) { + // System.out.println(file.getAbsolutePath()+"---> Seaching"); + if (file.getName().contains(containString)) { + retString = file.getName(); + break; + } + } + + } + + return retString; + + } + + + public File[] listFiles(String directoryName) { + + File directory = new File(directoryName); + + File[] fList = directory.listFiles(); + + return fList; + + } + + public static File getTheNewestFile(File dir, String ext) { + File theNewestFile = null; +// File dir = new File(filePath); + FileFilter fileFilter = new WildcardFileFilter("*." + ext); + File[] files = dir.listFiles(fileFilter); + + if (files.length > 0) { + /** The newest file comes first **/ + Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE); + theNewestFile = files[0]; + } + + return theNewestFile; + } + +}//end of class diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserDriver.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserDriver.java new file mode 100755 index 000000000..d63eeb686 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserDriver.java @@ -0,0 +1,275 @@ +package com.rl.qa.browsers; + +import com.google.common.io.Files; +import com.rl.qa.utils.CucumberContext; +import com.rl.qa.utils.BaseView; +import org.openqa.selenium.*; +import org.openqa.selenium.support.ui.*; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +import static org.junit.Assert.assertNotNull; + +public class BrowserDriver { + private static final Logger LOGGER = Logger.getLogger(BrowserDriver.class.getName()); + + private static final ThreadLocal driverThreadLocal = new ThreadLocal() { + protected WebDriver initialValue() { + WebDriver driver = BrowserFactory.createBrowser(); + + Runtime.getRuntime().addShutdownHook(new Thread(new BrowserCleanup(driver))); + + return driver; + } + }; + + private static int defaultWaitTime = 30; + + private static class BrowserCleanup implements Runnable { + private WebDriver driver; + + public void run() { + try { + driver.quit(); + CucumberContext.getCucumberContext().put("loggedIn", false); + } catch (Exception e) { + LOGGER.warning(e.getMessage()); + BaseView.takeScreenshot("BrowserNotFound.png"); + } + } + + public BrowserCleanup(WebDriver driver) { + this.driver = driver; + } + } + + public static WebDriver getCurrentDriver() { + return driverThreadLocal.get(); + } + + /** + * Captures a screen shot of the browser's current page writing the .png image + * to the specified file. + * + * @param imageFile - file to receive the .png image output + */ + public static void takeScreenshot(File imageFile) throws IOException { + TakesScreenshot ts = (TakesScreenshot) getCurrentDriver(); + File src = ts.getScreenshotAs(OutputType.FILE); + Files.copy(src, imageFile); + // extractJSErrors(); + } + + /*public static void extractJSErrors() { + JavaScriptError.readErrors(BrowserDriver.getCurrentDriver()); + final List jsErrors = JavaScriptError.readErrors(BrowserDriver.getCurrentDriver()); + if (!jsErrors.isEmpty()) { + LOGGER.info("JS Script Error: " + jsErrors.toString()); + } + }*/ + + public static void loadPage(URL url) throws Throwable{ + assertNotNull("Required field 'url' is null!", url); + loadPage(url.toString()); + } + + public static void logoutIfModalWindowAppears(String url) throws Throwable{ + try{ + BrowserDriver.getCurrentDriver().switchTo().defaultContent(); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(),8); + wait.until(ExpectedConditions + .textToBePresentInElement(BrowserDriver.getCurrentDriver() + .findElement(By.cssSelector("div.x-css-shadow+div.x-window div.x-title-text")), "Confirm logout")); + CucumberContext.getCucumberContext().put("loggedIn", false); + loadPage(url); + }catch(Exception e){ + System.out.println(e.getMessage()); + } + } + public static void loadPage(String url) throws Throwable{ + assertNotNull("Required field 'url' is null!", url); + + LOGGER.info("Directing browser to: " + url); + + WebDriver wd = getCurrentDriver(); + + //needed when scripts fails in child window + if (BaseView.mainWindowHandle != null) { + BrowserDriver.getCurrentDriver().switchTo().window(BaseView.mainWindowHandle); + } + wd.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); + + try { + wd.get(url); + logoutIfModalWindowAppears(url); + } catch (WebDriverException e) { + BaseView.takeScreenshot("redirect-to-url-fails.png"); + + LOGGER.info(String.format("Attempting to recover from this WebDriver exception: %s", e.getMessage())); + +// // Let start with a fresh browser as the current one is mis-behaving. +// try { +// getCurrentDriver().close(); +// driverThreadLocal.remove(); +// LOGGER.info("Closed the browser on browser error."); +// }catch(Exception ex){ +// } +//// getCurrentDriver().quit(); +// wd = getCurrentDriver(); +// CucumberContext.getCucumberContext().put("loggedIn", false); +// +// LOGGER.info("Created new WebDriver instance as old one was failing to respond."); +// +// wd.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); + wd.get(url); + + LOGGER.info("Browser at URL: " + url); + } + } + + /** + * Returns the domain name of the current page. Necessary to navigate to pages that can only be accessed through + * their address directly (e.g. Lx Administrator Page), since the environment URL varies between developers and + * testing environment. + * + * @return The domain name of the current environment + * @throws URISyntaxException + */ + public static String getDomainName() throws URISyntaxException { + URI uri = new URI(BrowserDriver.getCurrentDriver().getCurrentUrl()); + return uri.getHost(); + } + + public static WebElement waitForElement(WebElement elementToWaitFor) { + return waitForElement(elementToWaitFor, null); + } + + public static WebElement waitForElement(WebElement elementToWaitFor, Integer waitTimeInSeconds) { + return waitForElement(getCurrentDriver(), elementToWaitFor, waitTimeInSeconds); + } + + public static WebElement waitForElement(WebDriver driver, WebElement elementToWaitFor, Integer waitTimeInSeconds) { + if (waitTimeInSeconds == null) { + waitTimeInSeconds = defaultWaitTime; + } + + WebDriverWait wait = new WebDriverWait(driver, waitTimeInSeconds); + //return wait.until(ExpectedConditions.visibilityOf(elementToWaitFor)); + return wait.until(ExpectedConditions.elementToBeClickable(elementToWaitFor)); + } + + public static WebElement findElementWithTimeout(final By by, final long timeOut) throws InterruptedException { + Wait wait = new FluentWait(BrowserDriver.getCurrentDriver()) + .withTimeout(timeOut, TimeUnit.SECONDS) + .pollingEvery(500l, TimeUnit.MILLISECONDS) + .ignoring(NoSuchElementException.class) + .ignoring(StaleElementReferenceException.class); + + try { + return wait.until(ExpectedConditions.presenceOfElementLocated(by)); + } catch (TimeoutException te) { + throw new InterruptedException(te.getMessage()); + } + } + + public static List waitForAllElements(List elementsToWaitFor) { + return BrowserDriver.waitForAllElements(elementsToWaitFor, null); + } + + public static List waitForAllElements(List elementsToWaitFor, Integer waitTimeInSeconds) { + return BrowserDriver.waitForAllElements(BrowserDriver.getCurrentDriver(), elementsToWaitFor, waitTimeInSeconds); + } + + public static List waitForAllElements(WebDriver driver, List elementsToWaitFor, Integer waitTimeInSeconds) { + if (waitTimeInSeconds == null) { + waitTimeInSeconds = defaultWaitTime; + } + + WebDriverWait wait = new WebDriverWait(driver, waitTimeInSeconds); + return wait.until(ExpectedConditions.visibilityOfAllElements(elementsToWaitFor)); + } + + public static WebElement getParent(WebElement element) { + return element.findElement(By.xpath("..")); + } + + /** + * Copied from Selenium JavascriptExecutor.executeScript() javadoc. + *

+ * Executes JavaScript in the context of the currently selected frame or + * window. The script fragment provided will be executed as the body of + * an anonymous function. Within the script, use document to refer to the + * current document. Note that local variables will not be available once + * the script has finished executing, though global variables will persist. + *

+ * If the script has a return value (i.e. if the script contains a return + * statement), then the following steps will be taken: + *

+ * For an HTML element, this method returns a WebElement + * For a decimal, a Double is returned + * For a non-decimal number, a Long is returned + * For a boolean, a Boolean is returned + * For all other cases, a String is returned. + * For an array, return a List with each object following the + * rules above. We support nested lists. + *

+ * Unless the value is null or there is no return value, in which null + * is returned Arguments must be a number, a boolean, a String, WebElement, + * or a List of any combination of the above. An exception will be thrown + * if the arguments do not meet these criteria. The arguments will be made + * available to the JavaScript via the "arguments" magic variable, as if + * the function were called via "Function.apply" + */ + public static Object executeScript(String script) { + JavascriptExecutor je = (JavascriptExecutor) BrowserDriver.getCurrentDriver(); + + return je.executeScript(script); + } + + public static List getDropDownOptions(WebElement webElement) { + Select select = new Select(webElement); + return select.getOptions(); + } + + public static WebElement getDropDownOption(WebElement webElement, String value) { + WebElement option = null; + List options = getDropDownOptions(webElement); + for (WebElement element : options) { + if (element.getAttribute("value").equalsIgnoreCase(value)) { + option = element; + break; + } + } + return option; + } + + /** + * Waits for the element to be displayed, then clicks that element. + * + * @param webElement + */ + public static void clickElement(WebElement webElement) { + webElement = BrowserDriver.waitForElement(webElement); + webElement.isDisplayed(); + webElement.click(); + } + + /** + * Gets the visible text in the specified WebElement, with the white space before and after trimmed off. + * + * @param webElement - the WebElement to grab its visible text from. + * @return A String representation of the trimmed text that is visible in this WebElement. + */ + public static String getTextFromElement(WebElement webElement) { + webElement = BrowserDriver.waitForElement(webElement); + webElement.isDisplayed(); + return webElement.getText().trim(); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserFactory.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserFactory.java new file mode 100755 index 000000000..e21c1a45a --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserFactory.java @@ -0,0 +1,324 @@ +package com.rl.qa.browsers; +import com.gargoylesoftware.htmlunit.BrowserVersion; +import com.rl.qa.FileUtilities; +import com.rl.qa.utils.CucumberContext; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.firefox.FirefoxBinary; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxProfile; +import org.openqa.selenium.htmlunit.HtmlUnitDriver; +import org.openqa.selenium.ie.InternetExplorerDriver; +import org.openqa.selenium.remote.Augmenter; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import static junit.framework.Assert.assertNotNull; + +//import static com.rl.qa.utils.FileUtils.createDirectory; + +public class BrowserFactory { + //WebDriver driver; + //public static Scenario scenario; + + private static WebDriver createHtmlUnitDriver() { + // Create a pure Java based browser with a Javascript that emulates + // FIREFOX's Javascript engine. +// return new HtmlUnitDriver(BrowserVersion.FIREFOX_17); + return new HtmlUnitDriver(BrowserVersion.FIREFOX_38); + } + + private static WebDriver createInternetExplorerDriver() { + return new InternetExplorerDriver(); + } + + private static WebDriver createChromeDriver() { + File dataDir = new File(FileUtilities.getCWD(), "\\target"); + String path = dataDir.getPath(); + + FileUtilities dir = new FileUtilities(); +// createDirectory(path); + + Map prefs = new HashMap(); + prefs.put("download.default_directory", path); + + DesiredCapabilities caps = DesiredCapabilities.chrome(); + + ChromeOptions options = new ChromeOptions(); + options.setExperimentalOption("prefs", prefs); + caps.setCapability(ChromeOptions.CAPABILITY, options); + + System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe"); + return new Augmenter().augment(new ChromeDriver(caps)); + } + + private static WebDriver createFirefoxDriver(FirefoxProfile profile) { + return new Augmenter().augment(new FirefoxDriver(profile)); + } + + private static WebDriver createXvfbFirefoxDriver() { + FirefoxBinary firefoxBinary = new FirefoxBinary(new File("/usr/bin/firefox")); + + firefoxBinary.setEnvironmentProperty("DISPLAY", ":1"); + + return new Augmenter().augment(new FirefoxDriver(firefoxBinary, null)); + } + + /** + * Returns the user's download directory creating it if it was not found. + */ + public static String getBrowserDownloadsDir() throws IOException { + File downloads = new File(System.getProperty("user.home"), "Downloads"); + + if (!downloads.exists()) { + if (!downloads.mkdirs()) { + String msg = String.format("Unable to create directory '%s'", downloads.getCanonicalPath()); + + throw new IOException(msg); + } + } + + return downloads.getCanonicalPath(); + } + + private static void addAllBrowserSetup(WebDriver driver) { + driver.manage().deleteAllCookies(); + driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS); + driver.manage().window().maximize(); +// driver.manage().window().setPosition(new Point(0, 0)); +// driver.manage().window().setSize(new Dimension(1500, 800)); +// driver.manage().window().setPosition(new Point(0, 0)); +// java.awt.Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); +// Dimension dim = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight()); +// driver.manage().window().setSize(dim); +// Toolkit toolkit = Toolkit.getDefaultToolkit(); +// int Width = (int) toolkit.getScreenSize().getWidth(); +// int Height = (int)toolkit.getScreenSize().getHeight(); +// Dimension screenResolution = new Dimension(Width,Height); +// driver.manage().window().setSize(screenResolution); +// driver.manage().window().setSize(new Dimension(1500, 800)); + + } + + /** + * Create a selenium WebDriver that is appropriate for use with the specified + * type of browser. + * + * @param browserType - type of browser to create + * @return WebDriver + */ + public static WebDriver createBrowser(BrowserType browserType) { + WebDriver driver; + URL seleniumHub; + DesiredCapabilities capabilities; + + //original + File dataDir = new File(FileUtilities.getCWD(), "//target"); + String path = dataDir.getPath(); + + +// createDirectory(path); + + switch (browserType) { + case XVFB_FIREFOX: + driver = createXvfbFirefoxDriver(); + System.out.println("Created XVFB_FIREFOX browser driver."); + break; + case REMOTE_FIREFOX: + seleniumHub = CucumberContext.getSeleniumHub(); + + assertNotNull(String.format("Property [%s] is not defined!", CucumberContext.SELENIUM_HUB), seleniumHub); + + File profileDirectory = new File(path); + FirefoxProfile profile = new FirefoxProfile(profileDirectory); + + capabilities = DesiredCapabilities.firefox(); + + capabilities.setCapability("platform", "Windows 8"); + capabilities.setCapability("version", "35.0"); + + + capabilities.setCapability(FirefoxDriver.PROFILE, profile); + + driver = new RemoteWebDriver( + seleniumHub, capabilities + ); + + driver.manage().window().setPosition(new Point(0, 0)); + driver.manage().window().setSize(new Dimension(1500, 800)); + driver.manage().window().maximize(); + + System.out.format("Created REMOTE_FIREFOX browser, windows size: %s\n", driver.manage().window().getSize()); + //return driver; + break; + case REMOTE_CHROME: + seleniumHub = CucumberContext.getSeleniumHub(); + + assertNotNull(String.format("Property [%s] is not defined!", CucumberContext.SELENIUM_HUB), seleniumHub); + + //capabilities = DesiredCapabilities.chrome(); + //capabilities.setCapability("chrome.switches", "['--start-maximized']"); + //capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized")); + + //ChromeOptions options = new ChromeOptions(); + + //options.addArguments("start-maximized"); + //capabilities.setCapability(ChromeOptions.CAPABILITY, options); + + Map prefs = new HashMap(); + prefs.put("download.default_directory", path); + + capabilities = DesiredCapabilities.chrome(); + + capabilities.setCapability("platform", "Windows 7"); + capabilities.setCapability("version", "45.0"); + + ChromeOptions options = new ChromeOptions(); + options.setExperimentalOption("prefs", prefs); + capabilities.setCapability(ChromeOptions.CAPABILITY, options); + driver = new RemoteWebDriver( + seleniumHub, + capabilities + ); + + //JavascriptExecutor je = (JavascriptExecutor)driver; + + //je.executeScript("window.resizeTo(1024, 1024)"); + +// driver.manage().window().setPosition(new Point(0, 0)); +//// driver.manage().window().setSize(new Dimension(1024, 768)); +// driver.manage().window().setSize(new Dimension(1024, 1024)); +//// driver.manage().window().setSize(new Dimension(1500, 800)); +// Dimension d = new Dimension(1500, 800); +// driver.manage().window().setSize(d); + driver.manage().window().setPosition(new Point(0, 0)); + driver.manage().window().setSize(new Dimension(1500, 800)); +// driver.manage().window().maximize(); + + /* + try { + driver = new RemoteWebDriver( + new URL("http://127.0.0.1:9515"), // use of chromedriver without Selenium GRID + capabilities + ); + } catch (MalformedURLException e) { + return null; // not going to happen + } + */ + + System.out.format("Created REMOTE_CHROME browser, windows size: %s\n", driver.manage().window().getSize()); + break; + //return driver; + case REMOTE_IE: + seleniumHub = CucumberContext.getSeleniumHub(); + + assertNotNull(String.format("Property [%s] is not defined!", CucumberContext.SELENIUM_HUB), seleniumHub); + + capabilities = DesiredCapabilities.internetExplorer(); + + // The following is using the chromedriver directly without the selenium server. + driver = new RemoteWebDriver( + seleniumHub, + capabilities + ); + + System.out.format("Created REMOTE_CHROME browser, windows size: %s\n", driver.manage().window().getSize()); + //return driver; + case CHROME: + driver = createChromeDriver(); + System.out.println("Created CHROME browser driver."); + break; + case IE: + driver = createInternetExplorerDriver(); + System.out.println("Created IE browser driver."); + break; + case HTML_UNIT: + driver = createHtmlUnitDriver(); + System.out.println("Created HTML_UNIT browser driver."); + break; + case FIREFOX: + default: + profile = new FirefoxProfile(); + profile.setPreference("browser.download.folderList", 2); + profile.setPreference("browser.download.dir", path); + + profile.setPreference("browser.download.alertOnEXEOpen", false); + profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/html;" + + "text/xml; application/xml; " + + "application/excel; application/vnd.ms-excel; application/x-excel; application/x-msexcel;" + + "application/pdf;" + + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + profile.setPreference("browser.download.manager.showWhenStarting", false); + profile.setPreference("browser.download.manager.focusWhenStarting", false); + profile.setPreference("browser.helperApps.alwaysAsk.force", false); + profile.setPreference("browser.download.manager.alertOnEXEOpen", false); + profile.setPreference("browser.download.manager.closeWhenDone", false); + profile.setPreference("browser.download.manager.showAlertOnComplete", false); + profile.setPreference("browser.download.manager.useWindow", false); + profile.setPreference("browser.download.manager.showWhenStarting", false); + profile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false); + + driver = createFirefoxDriver(profile); + System.out.println("Created FIREFOX browser driver."); + driver.manage().window().setPosition(new Point(0, 0)); + driver.manage().window().setSize(new Dimension(1500, 800)); + driver.manage().window().maximize(); + break; + } + + addAllBrowserSetup(driver); + + return driver; + } + + /** + * Create a selenium WebDriver that is appropriate for use with the specified + * type of browser. The JVM property 'browser' may be used to specify the + * desired browser type with a default of 'firefox'. Supported browser types + * include: [firefox,chrome,ie]. + *

+ * Example of specifying browser type 'ie': + *

+ * -Dbrowser=ie + * + * @return WebDriver + */ + public static WebDriver createBrowser() { + + BrowserType bt = CucumberContext.getBrowserType(); + +// assertNotNull("Required property 'iwms.browser' not defined!", bt); + + return createBrowser(bt); + } +} + /* + @Before + public static void setUp(Scenario scenario) { + //this.Scenario = scenario; + } + + @After("@browser") + public void after(Scenario scenario) { + if (scenario.isFailed()) { + final byte[] screenshot = ((TakesScreenshot) driver) + .getScreenshotAs(OutputType.BYTES); + scenario.embed(screenshot, "//target//image/png"); //stick it in the report + + + } + driver.close(); + } + + } */ + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserType.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserType.java new file mode 100755 index 000000000..9dae68e80 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/browsers/BrowserType.java @@ -0,0 +1,31 @@ +package com.rl.qa.browsers; + +import static com.google.common.base.Strings.isNullOrEmpty; + +/** + * Types of support web browsers. + */ +public enum BrowserType { + XVFB_FIREFOX, + REMOTE_FIREFOX, + REMOTE_CHROME, + REMOTE_IE, + FIREFOX, + CHROME, + IE, + HTML_UNIT; + + public static BrowserType fromString(String name) { + if (isNullOrEmpty(name)) { + throw new IllegalArgumentException("Required argument 'name' is null/empty!"); + } + + for (BrowserType bt : BrowserType.values()) { + if (name.equalsIgnoreCase(bt.name())) { + return bt; + } + } + + throw new IllegalArgumentException(String.format("Specified name [%s] is unknown!", name)); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CFTSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CFTSteps.java new file mode 100755 index 000000000..da1f36f07 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CFTSteps.java @@ -0,0 +1,265 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CFTViews; +import cucumber.api.PendingException; +import cucumber.api.java.en.And; +import org.openqa.selenium.By; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.util.logging.Logger; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0097 on 21-06-2016. + */ +public class CFTSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I navigate to the \"([^\"]*)\"$") + public void I_navigate_to_the(String strLink) throws Throwable { + CFTViews.clickOnWorkZoneLink(); + } + + @And("^I click on the \"([^\"]*)\" link$") + public void I_click_on_the_link(String strLink) throws Throwable { + CFTViews.clickOntheLink(strLink); + } + + @And("^I select the \"([^\"]*)\" blueprint$") + public void I_select_the_blueprint(String strBlueprint) throws Throwable { + CFTViews.clickOntheCssselectorField("li[title='"+strBlueprint+"']"); + } + + @And("^I select the \"([^\"]*)\" blueprint and click on the Launch button$") + public void I_select_the_blueprint_and_click_on_the_Launch_button(String strBlueprint) throws Throwable { + CFTViews.selectBlueprintAndClickOnLaunchButton(strBlueprint); + } + + @And("^I click on the \"([^\"]*)\" button on confirmation popup window$") + public void I_click_on_the_button_on_confirmation_popup_window(String strButton) throws Throwable { + CFTViews.clickOnOKButton(strButton); + } + + @And("^I enter \"([^\"]*)\" unique stack name$") + public void I_enter_unique_stack_name(String strStackName) throws Throwable { + CFTViews.enterStackName(strStackName); + } + + @And("^I click on the submit button$") + public void I_click_on_the_submit_button() throws Throwable { + CFTViews.clickOnButtonButton(); + } + + @And("^I verify the following message \"([^\"]*)\"$") + public void I_verify_the_following_message(String strSearchText) { + try { + Thread.sleep(130000); + SeleniumUtil.waitUntilElementContainsText("id","instanceLogModalContainer",strSearchText,8,SeleniumUtilities.OBJWAITTIMEOUT); +// WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 560); +// assertTrue(wait.until(ExpectedConditions.textToBePresentInElement(By.tagName("*"), strSearchText))); + logger.info("Verified : " + strSearchText); + } catch (Exception e) { + try { + SeleniumUtil.getWebElementObject("xpath", "//*[contains(text(),\"" + strSearchText + "\")]"); + } catch (Exception ex) { + BaseView.takeScreenshot(strSearchText + ".png"); + logger.info("Error :" + e.getMessage()); + fail(e.getMessage()); + } + } + } + + @And("^I verify the \"([^\"]*)\" stack name and status \"([^\"]*)\" in cloudformation$") + public void I_verify_the_stack_name_and_status_in_cloudformation(String strStackName, String strStatus) throws Throwable { + CFTViews.verifyStackName(strStackName,strStatus); + } + + @And("^I click on more Info icon of \"([^\"]*)\" instance card$") + public void I_click_on_more_Info_icon_of_instance_card(String strCardName) throws Throwable { + CFTViews.clickOnMoreInfoofInstanceCard(strCardName); + } + + @And("^I extract IP address of \"([^\"]*)\" instance card$") + public void I_extract_IP_address_of_instance_card(String strCardName) throws Throwable { + CFTViews.getIPAddress(strCardName); + } + + @And("^I click on the \"([^\"]*)\" button on confirmation popup$") + public void I_click_on_the_button_on_confirmation_popup(String arg1) throws Throwable { + CFTViews.clickOnConfirmatinButton(); + } + + @And("^I collapse the first section \"([^\"]*)\"$") + public void I_collapse_the_first_section(String strSoftwareStack) throws Throwable { + CFTViews.clickOntheLink(strSoftwareStack); + } + + @And("^I expand the \"([^\"]*)\" section$") + public void I_expand_the_section(String Cloudformation) throws Throwable { + CFTViews.clickOntheLink(Cloudformation); + } + + @And("^I see the catalyst dashboard$") + public void I_see_the_catalyst_dashboard() throws Throwable { + CFTViews.seeDashboard(); + } + + @And("^I click on the \"([^\"]*)\" link to expend the tree$") + public void I_click_on_the_link_to_expend_the_tree(String strTreeHead) throws Throwable { + CFTViews.expendTheTree(strTreeHead); + } + + @And("^I verify the following message \"([^\"]*)\" on \"([^\"]*)\" popup window$") + public void I_verify_the_following_message_on_popup_window(String strPopWindowText,String strSearchText) { + try { + Thread.sleep(10000); + SeleniumUtil.waitUntilElementContainsText("xpath",".//*[contains(./text(),'"+strPopWindowText+"')]",strPopWindowText,SeleniumUtilities.OBJWAITTIMEOUT); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 160); + assertTrue(wait.until(ExpectedConditions.textToBePresentInElement(By.tagName("*"), strSearchText))); + logger.info("Verified : " + strSearchText); + } catch (Exception e) { + try { + SeleniumUtil.getWebElementObject("xpath", "//*[contains(text(),\"" + strSearchText + "\")]"); + } catch (Exception ex) { + BaseView.takeScreenshot(strSearchText + ".png"); + logger.info("Error :" + e.getMessage()); + fail(e.getMessage()); + } + } + } + + @And("^I navigate to the trackNew$") + public void I_navigate_to_the_trackNew() throws Throwable { + CFTViews.clickOnTrack(); + } + + @And("^I click on the line chart \"([^\"]*)\"$") + public void I_click_on_the_line_chart(String strLabel) throws Throwable { + CFTViews.clickOnLineChartNotifications(strLabel); + } + + @And("^I click on the file \"([^\"]*)\"$") + public void I_click_on_the_file(String strLabel) throws Throwable { + CFTViews.clickOnFileNotifications(strLabel); + } + + @And("^I click on the desktop \"([^\"]*)\"$") + public void I_click_on_the_desktop(String strLabel) throws Throwable { + CFTViews.clickOnDesktopNotifications(strLabel); + } + + @And("^I click on the \"([^\"]*)\" tab$") + public void I_click_on_the_tab(String strLink) throws Throwable { + CFTViews.clickOnLink(strLink); + } + + @And("^I verify the Public IP address exist in \"([^\"]*)\" instance$") + public void I_verify_the_Public_IP_address_exist_in_instance(String strCardName) throws Throwable { +// span[class='ip-cell-public'] +// span[class='ip-cell-private'] + CFTViews.verifyPublicIPAddress(strCardName); + } + + @And("^I extract Private IP address of \"([^\"]*)\" instance card$") + public void I_extract_Private_IP_address_of_instance_card(String strCardName) throws Throwable { + CFTViews.getPrivateIPAddress(strCardName); + } + + @And("^I switch to visible frame$") + public void I_switch_to_visible_frame() throws Throwable { + CFTViews.switchToFrame(); + } + + @And("^I switch to default frame$") + public void I_switch_to_default_frame() throws Throwable { + SeleniumUtil.switchTodefaultContent(); + } + + + @And("^I select the \"([^\"]*)\" from drop down$") + public void iSelectTheFromDropDown(String orgName) throws Throwable { + CFTViews.selectOrg(orgName); + } + + @And("^I click on \"([^\"]*)\" to expand it$") + public void iClickOnToExpandIt(String configStackPara) throws Throwable { + CFTViews.clickOnConfigStackParaLink(configStackPara); + } + + @And("^I enter \"([^\"]*)\" in the \"([^\"]*)\" edit box$") + public void iEnterInTheEditBox(String stackPara, String webEleAttribute) throws Throwable { + CFTViews.enterStackPara(stackPara,webEleAttribute); + + } + + @And("^I enter \"([^\"]*)\" in Username Input edit box$") + public void iEnterInUsernameInputEditBox(String instanceUserName) throws Throwable { + CFTViews.enterInstanceUserName(instanceUserName); + } + + @And("^I expand \"([^\"]*)\"$") + public void iExpand(String blueprintType) throws Throwable { + CFTViews.clickOnBlueprintType(blueprintType); + } + + @And("^I enter \"([^\"]*)\" on popup window$") + public void iEnterOnPopupWindow(String uniqueStackName) throws Throwable { + CFTViews.enterUniqueStackName(uniqueStackName); + } + + @And("^I click on Refresh button$") + public void iClickOnRefreshButton() throws Throwable { + CFTViews.refreshCFTStackPage(); + } + @And("^I verify the \"([^\"]*)\" stack name and status CREATE_IN_PROGRESS in CFT Stacks$") + public void iVerifyTheStackNameAndStatusCREATE_IN_PROGRESSInCFTStacks(String cftName) throws Throwable { + CFTViews.verifyStatusCreateInProgress(cftName); + } + + @And("^I verify the \"([^\"]*)\" stack name and status CREATE_COMPLETE in CFT Stacks$") + public void iVerifyTheStackNameAndStatusCREATE_COMPLETEInCFTStacks(String cftName) throws Throwable { + CFTViews.verifyStatusCreateComplete(); + + } + + @And("^I Click on \"([^\"]*)\" link$") + public void iClickOnLink(String strLinkSaid) throws Throwable { + CFTViews.clickonTheLinkSaid(strLinkSaid); + + } + + @And("^I Click on \"([^\"]*)\" Tab provided$") + public void iClickOnTabProvided(String strCloudFormationTab) throws Throwable { + CFTViews.clickonCloudformationTab(strCloudFormationTab); + } + + + @And("^I Verify the Cloudformation Blueprint is created \"([^\"]*)\"$") + public void iVerifyTheCloudformationBlueprintIsCreated(String strVerifyBlueprint) throws Throwable { + CFTViews.VerifyCloudFormationBlueprint(strVerifyBlueprint); + } + + @And("^I click on the link workzone$") + public void iClickOnTheLinkWorkzone() throws Throwable { + CFTViews.clickOnWorkZoneLink(); + } + + @And("^I Click on \"([^\"]*)\" link provided$") + public void iClickOnLinkProvided(String arg0) throws Throwable { + CFTViews.clickOnBlueprints(); + + } + + @And("^I Verify the SoftwareStack Blueprint is created \"([^\"]*)\"$") + public void iVerifyTheSoftwareStackBlueprintIsCreated(String strSoftwareStack) throws Throwable { + CFTViews.VerifySoftwareStackBlueprint(strSoftwareStack); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ChefServerSetupSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ChefServerSetupSteps.java new file mode 100755 index 000000000..12507df3f --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ChefServerSetupSteps.java @@ -0,0 +1,156 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.ChefServerSetupViews; +import cucumber.api.PendingException; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.PageFactory; + +import java.util.Iterator; +import java.util.logging.Logger; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 20-07-2016. + */ +public class ChefServerSetupSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I Enter the \"([^\"]*)\" in name edit box$") + public void iEnterTheInNameEditBox(String chefServerName) throws Throwable { + ChefServerSetupViews.enterServerName(chefServerName); + } + + @And("^I Enter \"([^\"]*)\" in User Name edit box$") + public void iEnterInUserNameEditBox(String userName) throws Throwable { + ChefServerSetupViews.enterUserName(userName); + } + + @And("^I Enter \"([^\"]*)\" in URL edit box$") + public void iEnterInURLEditBox(String url) throws Throwable { + ChefServerSetupViews.enterURL(url); + } + + @And("^I browse pem file for chef server$") + public void iBrowsePemFileForChefServer() throws Throwable { + ChefServerSetupViews.BrowsePemFileForChefServer(); + } + + @And("^I browse knife file for chef server$") + public void iBrowseKnifeFileForChefServer() throws Throwable { + ChefServerSetupViews.BrowseKnifeFileForChefServer(); + } + + @And("^I select the \"([^\"]*)\" and click on corresponding \"([^\"]*)\" Button$") + public void iSelectTheAndClickOnCorrespondingButton(String cherServerName ,String Import_Node) throws Throwable { + ChefServerSetupViews.chefServerEditButton(cherServerName,Import_Node); + } + + @And("^I clear the \"([^\"]*)\" already present in name edit box$") + public void iClearTheAlreadyPresentInNameEditBox(String arg0) throws Throwable { + ChefServerSetupViews.clearNameField(); + } + + + @Then("^I verify \"([^\"]*)\" Link is displayed or not$") + public void iVerifyLinkIsDisplayedOrNot(String Nodes) throws Throwable { + try { + SeleniumUtil.waitForElementIsClickable("xpath","//a[text()='Nodes']",8,SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.waitUntilElementContainsText("xpath","//a[text()='Nodes']",Nodes,8,SeleniumUtilities.OBJWAITTIMEOUT));{ + logger.info("Verified : " +Nodes); +// }else{ +// logger.info("Verified : " +Nodes); + } + } catch (Exception e) { + try { + SeleniumUtil.getWebElementObject("xpath", "//a[text()='Nodes']"); + } catch (Exception ex) { + BaseView.takeScreenshot(Nodes + ".png"); + logger.info("Error :" + e.getMessage()); + fail(e.getMessage()); + } + } + + } + + @Then("^I verify that message \"([^\"]*)\" is displayed$") + public void iVerifyThatMessageIsDisplayed(String expectedMsg) throws Throwable { + try { + WebDriver driver=SeleniumUtil.getWebDriver(); + Iterator i = driver.getWindowHandles().iterator(); + while (i.hasNext()) { + String parentBrowser=i.next(); + String childBrowser =i.next(); + driver.switchTo().window(childBrowser); + assertTrue(SeleniumUtil.isElementExist("id","chefAccountMsg")); + logger.info("Verified : Chef Account is Displayed"); + driver.close(); + driver.switchTo().window(parentBrowser); + } + } catch (Exception e) { + BaseView.takeScreenshot(expectedMsg + ".png"); + logger.info("Error :" + e.getMessage()); + fail(e.getMessage()); + } + } + @Then("^I verify that message \"([^\"]*)\" on data bag page is displayed$") + public void iVerifyThatMessageOnDataBagPageIsDisplayed(String expectedMsg) throws Throwable { + try { + SeleniumUtil.waitForElementIsClickable("xpath","//h4[contains(text(),'Data Bags & Items')]",8,SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath","//h4[contains(text(),'Data Bags & Items')]",expectedMsg,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified : " + expectedMsg); + } + } catch (Exception e) { + BaseView.takeScreenshot(expectedMsg + ".png"); + logger.info("Error :" + e.getMessage()); + fail(e.getMessage()); + } + } + + @Then("^I verify created \"([^\"]*)\" in chef server table$") + public void iVerifyCreatedInChefServerTable(String chefServerName) throws Throwable { + ChefServerSetupViews.verifyChefServerName(chefServerName); + + } + + + @And("^I verify select organization is disabled$") + public void iVerifySelectOrganizationIsDisabled() throws Throwable { + ChefServerSetupViews.verifySelectOrgISDisabled(); + } + + @Then("^I verify created \"([^\"]*)\" is deleted$") + public void iVerifyCreatedChefServerIsDeleted(String chefServerName) throws Throwable { + ChefServerSetupViews.verifyChefServerIsDeleted(chefServerName); + } + + + @Then("^I verify \"([^\"]*)\" with \"([^\"]*)\" in the Chef Server table$") + public void iVerifyWithInTheChefServerTable(String chefServerName, String chefUserName) throws Throwable { + ChefServerSetupViews.verifyServerDetails(chefServerName,chefUserName); + } + + @And("^I upload pem file \"([^\"]*)\"$") + public void iUploadPemFile(String fileName) throws Throwable { + ChefServerSetupViews.uploadPemFile(fileName); + } + + @And("^I upload knife file \"([^\"]*)\"$") + public void iUploadKnifeFile(String fileName) throws Throwable { + ChefServerSetupViews.uploadKnifeFile(fileName); + } + + @And("^I select \"([^\"]*)\" from the Drop Down available$") + public void iSelectFromTheDropDownAvailable(String strOrgname) throws Throwable { + ChefServerSetupViews.selectTheOrg(strOrgname); + + } +} + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigBlueprintForOSImageUsingProAWSSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigBlueprintForOSImageUsingProAWSSteps.java new file mode 100755 index 000000000..adc866fb5 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigBlueprintForOSImageUsingProAWSSteps.java @@ -0,0 +1,43 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.ConfigBlueprintForOSImageUsingProAWSViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 23-09-2016. + */ +public class ConfigBlueprintForOSImageUsingProAWSSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I see Choose Operating System is disabled$") + public void iSeeChooseOperatingSystemIsDisabled() throws Throwable { + ConfigBlueprintForOSImageUsingProAWSViews.verifyChooseOSIsDisabled(); + } + + @And("^I see Choose Provider is disabled$") + public void iSeeChooseProviderIsDisabled() throws Throwable { + ConfigBlueprintForOSImageUsingProAWSViews.verifyChooseProviderIsDisabled(); + } + + @And("^I see Choose Available Images is disabled$") + public void iSeeChooseAvailableImagesIsDisabled() throws Throwable { + ConfigBlueprintForOSImageUsingProAWSViews.verifyChooseAvailableImages(); + } + + @And("^I see Choose Organization is disabled$") + public void iSeeChooseOrganizationIsDisabled() throws Throwable { + ConfigBlueprintForOSImageUsingProAWSViews.verifyChooseOrgIsDisabled(); + } + + @Then("^I verify launch blueprint button is dispalyed$") + public void iVerifyLaunchBlueprintButtonIsDispalyed() throws Throwable { + ConfigBlueprintForOSImageUsingProAWSViews.verifyLaunchButtonISDisplayed(); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigBlueprintForSSTempUsingProAWSSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigBlueprintForSSTempUsingProAWSSteps.java new file mode 100755 index 000000000..2e0f65707 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigBlueprintForSSTempUsingProAWSSteps.java @@ -0,0 +1,89 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.ConfigBlueprintForSSTempUsingProAWSViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 10-09-2016. + */ +public class ConfigBlueprintForSSTempUsingProAWSSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @Then("^I verify \"([^\"]*)\" present in \"([^\"]*)\" page$") + public void iVerifyPresentInPage(String blueprintName, String pageName) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.verifyBlueprintInWorkZone(blueprintName,pageName); + } + + @And("^I click on \"([^\"]*)\" of the \"([^\"]*)\"$") + public void iClickOnOfThe(String moreInfo, String blueprintName) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnMoreInfo(moreInfo,blueprintName); + } + + @And("^I click on the \"([^\"]*)\" button on instance log popup$") + public void iClickOnTheButtonOnInstanceLogPopup(String arg0) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnClose(); + } + + @And("^I select the desired \"([^\"]*)\"$") + public void iSelectTheDesired(String blueprintName) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.selectBlueprint(blueprintName); + } + + @And("^I click on copy Blueprint$") + public void iClickOnCopyBlueprint() throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnCopyBlueprint(); + } + + @And("^I select \"([^\"]*)\" from \"([^\"]*)\" drop down on select target popup$") + public void iSelectFromDropDownOnSelectTargetPopup(String name, String idOfElement) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.selectParametersOnPopupWindow(name,idOfElement); + } + + @And("^I click on \"([^\"]*)\" button on the select target popup$") + public void iClickOnButtonOnTheSelectTargetPopup(String buttonText) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnSave(buttonText); + } + + @And("^I select the \"([^\"]*)\" and click on assigned \"([^\"]*)\"$") + public void iSelectTheAndClickOnAssigned(String proName, String envName) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnEnv(proName,envName); + } + + @And("^I click on \"([^\"]*)\" button to delete the blueprint$") + public void iClickOnButtonToDeleteTheBlueprint(String buttonTitle) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnDeleteBlueprint(buttonTitle); + } + + @Then("^I verify \"([^\"]*)\" is deleted$") + public void iVerifyIsDeleted(String blueprintName) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.verifyBlueprintDeleted(blueprintName); + } + + @And("^I click on \"([^\"]*)\" button of \"([^\"]*)\"$") + public void iClickOnButtonOf(String buttonTitle, String blueprintName) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnEditBlueprintButton(buttonTitle,blueprintName); + } + + @And("^I click on the Settings$") + public void iClickOnTheSettings() throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnSettings(); + } + + @And("^I click on \"([^\"]*)\" on blueprint page$") + public void iClickOnOnBlueprintPage(String title) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.deleteBlueprint(title); + } + + @And("^I click on the \"([^\"]*)\" button on \"([^\"]*)\" popup window$") + public void iClickOnTheButtonOnPopupWindow(String arg0, String arg1) throws Throwable { + ConfigBlueprintForSSTempUsingProAWSViews.clickOnDeleteOnConfirmationPopup(); + } + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigureNexusServerSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigureNexusServerSteps.java new file mode 100755 index 000000000..3430a4b91 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigureNexusServerSteps.java @@ -0,0 +1,33 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.ConfigureNexusServerViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 09-08-2016. + */ +public class ConfigureNexusServerSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @Then("^I verify \"([^\"]*)\" in the nexus server management table$") + public void iVerifyInTheNexusServerManagementTable(String nexusServerName) throws Throwable { + ConfigureNexusServerViews.verifyNexusServerName(nexusServerName); + } + + @Then("^I verify \"([^\"]*)\" with \"([^\"]*)\" in the nexus server management table$") + public void iVerifyWithInTheNexusServerManagementTable(String nexusServerName, String nexusServerDetails) throws Throwable { + ConfigureNexusServerViews.verifyNexusServerInfo(nexusServerName,nexusServerDetails); + } + + @And("^I select \"([^\"]*)\" from the select box Nexus Configuration Management page$") + public void iSelectFromTheSelectBoxNexusConfigurationManagementPage(String orgName) throws Throwable { + ConfigureNexusServerViews.selectOrgInNexusConfigPage(orgName); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigureProviderSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigureProviderSteps.java new file mode 100755 index 000000000..8b5f99b08 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigureProviderSteps.java @@ -0,0 +1,123 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.ConfigureProviderViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 02-08-2016. + */ +public class ConfigureProviderSteps { + + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I select provider type \"([^\"]*)\"$") + public void iSelectProviderType(String providerType) throws Throwable { + ConfigureProviderViews.selectProviderType(providerType); + + } + + @And("^I click on \"([^\"]*)\" User Access Key$") + public void iClickOnUserAccessKey(String buttonID) throws Throwable { + ConfigureProviderViews.clickCredentialSelButton(buttonID); + } + + @And("^I select \"([^\"]*)\" from the drop down$") + public void iSelectFromTheDropDown(String orgName) throws Throwable { + ConfigureProviderViews.selectOrg(orgName); + } + + @And("^I select \"([^\"]*)\" from the region select box$") + public void iSelectFromTheRegionSelectBox(String region) throws Throwable { + ConfigureProviderViews.selectRegion(region); + } + + @And("^I select \"([^\"]*)\" from the key pair select box$") + public void iSelectFromTheKeyPairSelectBox(String keyPair) throws Throwable { + ConfigureProviderViews.selectKeyPair(keyPair); + } + + @And("^I browse pem file for provider$") + public void iBrowsePemFileForProvider() throws Throwable { + ConfigureProviderViews.browsePemFileForProvider(); + } + + @And("^I verify the created provider \"([^\"]*)\" in Providers list$") + public void iVerifyTheCreatedProviderInProvidersList(String providerName) throws Throwable { + ConfigureProviderViews.verifyProvidersName(providerName); + } + + @Then("^I verify the following message \"([^\"]*)\" on popup window$") + public void iVerifyTheFollowingMessageOnPopupWindow(String actMsg) throws Throwable { + ConfigureProviderViews.verifyMessage(actMsg); + } + + @And("^I browse \"([^\"]*)\" file for open stack provider$") + public void iBrowseFileForOpenStackProvider(String openStackpemFile) throws Throwable { + ConfigureProviderViews.browseOpenStackPemFile(openStackpemFile); + } + + @Then("^I verify \"([^\"]*)\" in the provider table$") + public void iVerifyInTheProviderTable(String providerName) throws Throwable { + ConfigureProviderViews.verifyProviderName(providerName); + } + + @And("^I verify select provider type is disabled$") + public void iVerifySelectProviderTypeIsDisabled() throws Throwable { + ConfigureProviderViews.verifySelProviderTypeisDisabled(); + } + + @And("^I verify \"([^\"]*)\" is disabled$") + public void iVerifyIsDisabled(String credentialsAccessKeys) throws Throwable { + ConfigureProviderViews.verifyCredentialsAccessKeyIsDisabled(credentialsAccessKeys); + } + + @And("^I verify select organization is disabled in edit provider page$") + public void iVerifySelectOrganizationIsDisabledInEditProviderPage() throws Throwable { + ConfigureProviderViews.verifySelectOrgIsDisabled(); + } + + @And("^I verify select region is disabled in edit provider page$") + public void iVerifySelectRegionIsDisabledInEditProviderPage() throws Throwable { + ConfigureProviderViews.verifySelectRegionIsDisabled(); + } + + @And("^I verify select key pair is disabled in edit provider page$") + public void iVerifySelectKeyPairIsDisabledInEditProviderPage() throws Throwable { + ConfigureProviderViews.verifySelKeyPairIsDisabled(); + } + + + @Then("^I verify \"([^\"]*)\" with \"([^\"]*)\" in the provider table$") + public void iVerifyWithInTheProviderTable(String providerName, String providerInfo) throws Throwable { + ConfigureProviderViews.verifyProviderInfo(providerName,providerInfo); + } + + + @And("^I select \"([^\"]*)\" from the dropdown$") + public void iSelectFromTheDropdown(String orgName) throws Throwable { + ConfigureProviderViews.OrgSelct(orgName); + } + + @And("^I select \"([^\"]*)\" from the select box in new provider page$") + public void iSelectFromTheSelectBoxInNewProviderPage(String orgName) throws Throwable { + ConfigureProviderViews.selectOrgInNewAWSPage(orgName); + } + + @And("^I browse pem file for azure provider$") + public void iBrowsePemFileForAzureProvider() throws Throwable { + ConfigureProviderViews.browseAzurePemFile(); + + } + + @And("^I browse private key file for azure provider$") + public void iBrowsePrivateKeyFileForAzureProvider() throws Throwable { + ConfigureProviderViews.browseAzurePrivateKeyFile(); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigurePuppetServerSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigurePuppetServerSteps.java new file mode 100755 index 000000000..a333b97fd --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ConfigurePuppetServerSteps.java @@ -0,0 +1,44 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.ConfigurePuppetServerViews; +import cucumber.api.java.en.And; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; +/** + * Created by RLE0372 on 01-08-2016. + */ +public class ConfigurePuppetServerSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + + @And("^I click on puppet server link$") + public void iClickOnPuppetServerLink() throws Throwable { + ConfigurePuppetServerViews.clickOnPuppetServerLink(); + } + + + @And("^I enter the \"([^\"]*)\" in edit box$") + public void iEnterTheInEditBox(String puppetServerName) throws Throwable { + ConfigurePuppetServerViews.enterPuppetServerName(puppetServerName); + } + + + @And("^I Enter puppet server \"([^\"]*)\" in User Name edit box$") + public void iEnterPuppetServerInUserNameEditBox(String userName) throws Throwable { + ConfigurePuppetServerViews.enterUserName(userName); + } + + @And("^I enter \"([^\"]*)\" in edit box$") + public void iEnterInEditBox(String hostName) throws Throwable { + ConfigurePuppetServerViews.enterHostName(hostName); + } + + @And("^I enter \"([^\"]*)\" in password edit box$") + public void iEnterInPasswordEditBox(String password) throws Throwable { + ConfigurePuppetServerViews.enterPuppetPassword(password); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelBGroupSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelBGroupSteps.java new file mode 100755 index 000000000..5dffc18c0 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelBGroupSteps.java @@ -0,0 +1,95 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CreateEditDelBGroupViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 20-07-2016. + */ +public class CreateEditDelBGroupSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + @And("^I click on Business Groups Link$") + public void iClickOnBusinessGroupsLink() throws Throwable { + CreateEditDelBGroupViews.clickBGroupLink(); + } + + @And("^I click on New BGroup button$") + public void iClickOnNewBGroupButton() throws Throwable { + CreateEditDelBGroupViews.clickOnNewBGroup(); + + } + @And("^I enter the \"([^\"]*)\" name in Business Group name$") + public void iEnterTheNameInBusinessGroupName(String bGroupName) throws Throwable { + CreateEditDelBGroupViews.enterBGroupName(bGroupName); + } + +// @And("^I click on Organization select button$") +// public void iClickOnOrganizationSelectButton() throws Throwable { +// CreateEditDelBGroupViews.clickOnOrgSelectButton(); +// } + + @And("^I enter \"([^\"]*)\" in the search box$") + public void iEnterInTheSearchBox(String org_Name) throws Throwable { + CreateEditDelBGroupViews.enterOrgName(org_Name); + } + + + @And("^I click on \"([^\"]*)\" Edit button$") + public void iClickOnEditButton(String bGroup) throws Throwable { + CreateEditDelBGroupViews.clickOnEditBGroup(bGroup); + } + + @And("^I clear the product group name field$") + public void iClearTheProductGroupNameField() throws Throwable { + CreateEditDelBGroupViews.clearField(); + } + + @And("^I enter another \"([^\"]*)\" in edit box$") + public void iEnterAnotherBGrpInEditBox(String newBGrpName) throws Throwable { + CreateEditDelBGroupViews.enterNewBGrpName(newBGrpName); + } + + @And("^I click on \"([^\"]*)\" delete bGroup button$") + public void iClickOnDeleteBGroupButton(String editedBGrp) throws Throwable { + CreateEditDelBGroupViews.delEditedBGroup(editedBGrp); + } + + @And("^I click on Organizations link in the settings tree$") + public void iClickOnOrganizationsLinkInTheSettingsTree() throws Throwable { + CreateEditDelBGroupViews.clickOnOrgLinkInSettTree(); + } + + + @Then("^I verify the created \"([^\"]*)\" in Business group table$") + public void iVerifyTheCreatedInBusinessGroupTable(String businessGroup) throws Throwable { + CreateEditDelBGroupViews.verifyCreatedBGroup(businessGroup); + + } + + @Then("^I verify the edited \"([^\"]*)\" in Business group table$") + public void iVerifyTheEditedInBusinessGroupTable(String editedBGroup) throws Throwable { + CreateEditDelBGroupViews.verifyEditedBGroup(editedBGroup); + } + + @Then("^I verify the \"([^\"]*)\" is deleted from the Business Group table$") + public void iVerifyTheIsDeletedFromTheBusinessGroupTable(String bGroup) throws Throwable { + CreateEditDelBGroupViews.verifyDeletedBGroup(bGroup); + } + + @Then("^I verify \"([^\"]*)\" with assigned \"([^\"]*)\" in the Business group table$") + public void iVerifyWithAssignedInTheBusinessGroupTable(String bGroup, String org) throws Throwable { + CreateEditDelBGroupViews.verifyAssignedOrg(bGroup,org); + } + + @And("^I select \"([^\"]*)\" from the Drop Down$") + public void iSelectFromTheDropDown(String orgName) throws Throwable { + CreateEditDelBGroupViews.selectBusinessGroup(orgName); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelDesignerSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelDesignerSteps.java new file mode 100755 index 000000000..fe103ab3a --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelDesignerSteps.java @@ -0,0 +1,156 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CreateEditDelDesignerViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by rle0346 on 3/8/16. + */ +public class CreateEditDelDesignerSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I Click on \"([^\"]*)\" Link$") + public void iClickOnLink(String StrDesignerlink) throws Throwable { + CreateEditDelDesignerViews.clickOnUsersSetupLink(StrDesignerlink); + } + + @And("^I Click on \"([^\"]*)\" Link in the link$") + public void iClickOnLinkInTheLink(String strUserLink) throws Throwable { + CreateEditDelDesignerViews.clickOnUsersLink(strUserLink); + + } + + @And("^I Click on New Button of Users page$") + public void iClickOnNewButtonOfUsersPage() throws Throwable { + CreateEditDelDesignerViews.clickOnNewButton(); + } + + @And("^I Enter the \"([^\"]*)\" User Login Name$") + public void iEnterTheUserLoginName(String strDesignerName) throws Throwable { + CreateEditDelDesignerViews.enterLoginName(strDesignerName); + } + + @And("^I Enter the \"([^\"]*)\" of the User$") + public void iEnterTheOfTheUser(String strEmailAddress) throws Throwable { + CreateEditDelDesignerViews.enterEmailAddress(strEmailAddress); + + } + + + @And("^I Enter the \"([^\"]*)\" of the User field$") + public void iEnterTheOfTheUserField(String strPassword) throws Throwable { + CreateEditDelDesignerViews.enterPassword(strPassword); + } + + + @And("^I Enter the \"([^\"]*)\" of User field$") + public void iEnterTheOfUserField(String strConfPassword) throws Throwable { + CreateEditDelDesignerViews.enterConfirmPassword(strConfPassword); + } + + @And("^I Click on Org Dropdown and select \"([^\"]*)\"$") + public void iClickOnOrgDropdownAndSelect(String strOrganization) throws Throwable { + CreateEditDelDesignerViews.selectOrganization(strOrganization); + + } + + @And("^I Select the Role as \"([^\"]*)\"$") + public void iSelectTheRoleAs(String strRole) throws Throwable { + CreateEditDelDesignerViews.selectRole(strRole); + + } + + @And("^I Assign the Teams for the User with respect to \"([^\"]*)\"$") + public void iAssignTheTeamsForTheUserWithRespectTo(String strOrganization) throws Throwable { + CreateEditDelDesignerViews.selectTeam(strOrganization); + + } + + + @And("^I Click on Save Button of User creation page$") + public void iClickOnSaveButtonOfUserCreationPage() throws Throwable { + CreateEditDelDesignerViews.clickSaveButton(); + } + + + @And("^I Click on Edit Button the \"([^\"]*)\" user created$") + public void iClickOnEditButtonTheUserCreated(String strDesigner) throws Throwable { + CreateEditDelDesignerViews.clickEditDesignerButton(strDesigner); + + } + + + @Then("^I Verify the \"([^\"]*)\" User is created$") + public void iVerifyTheUserIsCreated(String strDesigner) throws Throwable { + CreateEditDelDesignerViews.verifyDesignerUserCreation(strDesigner); + + } + + @And("^I Verify the Login name is disabled$") + public void iVerifyTheLoginNameIsDisabled() throws Throwable { + CreateEditDelDesignerViews.VerifyLoginNameDisabled(); + + } + + @And("^I Click on Update Password tick$") + public void iClickOnUpdatePasswordTick() throws Throwable { + CreateEditDelDesignerViews.clickOnUpdatePasswordCheckbox(); + } + + + @And("^I Click on Delete button of the \"([^\"]*)\" user created$") + public void iClickOnDeleteButtonOfTheUserCreated(String strDesigner) throws Throwable { + CreateEditDelDesignerViews.clickOnDeleteButton(strDesigner); + + } + + @And("^I Click on \"([^\"]*)\" Button to remove the Designer user$") + public void iClickOnButtonToRemoveTheDesignerUser(String strOK) throws Throwable { + CreateEditDelDesignerViews.clickOnOkButton(strOK); + } + + @And("^I Verify the \"([^\"]*)\" is updated$") + public void iVerifyTheIsUpdated(String strEmailAddress) throws Throwable { + CreateEditDelDesignerViews.verfiyEmailAddressUpdated(strEmailAddress); + } + + @And("^I Assign the Teams for the SuperAdmin User with respect to \"([^\"]*)\"$") + public void iAssignTheTeamsForTheSuperAdminUserWithRespectTo(String strDefaultTeam) throws Throwable { + CreateEditDelDesignerViews.selectDefaultTeam(strDefaultTeam); + + } + + @Then("^I Verify the \"([^\"]*)\" User with this \"([^\"]*)\" is created$") + public void iVerifyTheUserWithThisIsCreated(String strDesigner, String strEmailAddress) throws Throwable { + CreateEditDelDesignerViews.VerifyEmailAddress(strDesigner, strEmailAddress); + + } + + @Then("^I Verify the \"([^\"]*)\" User with this \"([^\"]*)\" created$") + public void iVerifyTheUserWithThisCreated(String strDesigner, String strDesignerRole) throws Throwable { + CreateEditDelDesignerViews.VerifyDesignerRoleInTable(strDesigner, strDesignerRole); + } + + + @Then("^I Verify the \"([^\"]*)\" User with this \"([^\"]*)\" is available$") + public void iVerifyTheUserWithThisIsAvailable(String strDesigner, String strOrganization) throws Throwable { + CreateEditDelDesignerViews.VerifyOrganizationInTable(strDesigner, strOrganization); + } + + @Then("^I select the \"([^\"]*)\" and verify \"([^\"]*)\" Button is enabled$") + public void iSelectTheAndVerifyButtonIsEnabled(String strOrganization, String strEdit) throws Throwable { + CreateEditDelDesignerViews.verifyButtonIsEnabled(strOrganization, strEdit); + } + + @Then("^I Verify the \"([^\"]*)\" user is deleted$") + public void iVerifyTheUserIsDeleted(String strDesigner) throws Throwable { + CreateEditDelDesignerViews.verifyDeletedUser(strDesigner); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelDockerSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelDockerSteps.java new file mode 100755 index 000000000..38f59c3c8 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelDockerSteps.java @@ -0,0 +1,104 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CreateEditDelDockerViews; +import cucumber.api.PendingException; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 01-08-2016. + */ +public class CreateEditDelDockerSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + + @And("^^I click on \"([^\"]*)\" link$") + public void iClickOnLink(String linkText) throws Throwable { + CreateEditDelDockerViews.clickOnDevopsSetup(linkText); + } + + @And("^I enter \"([^\"]*)\" in user id edit box$") + public void iEnterInUserIdEditBox(String userId) throws Throwable { + CreateEditDelDockerViews.enterUserID(userId); + } + + @And("^I Enter \"([^\"]*)\" in docker \"([^\"]*)\"$") + public void iEnterInDocker(String dockerName, String dockerreponame) throws Throwable { + CreateEditDelDockerViews.enterDockerHubRegistry(dockerName,dockerreponame); + } + + @And("^I enter \"([^\"]*)\" in docker hub registry edit box$") + public void iEnterInDockerHubRegistryEditBox(String DocerHubRegName) throws Throwable { + CreateEditDelDockerViews.enterDockerHubRegistryName(DocerHubRegName); + } + + @And("^I verify \"([^\"]*)\" page is displayed$") + public void iVerifyPageIsDisplayed(String editDocker) throws Throwable { + try { +// SeleniumUtil.waitForElementIsClickable("xpath","",8,SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.waitUntilElementContainsText("xpath","//*[contains(text(),'Edit Docker')]","Edit Docker",8,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified : " + editDocker); + } + } catch (Exception e) { + try { + SeleniumUtil.getWebElementObject("xpath", "//a[text()='Nodes']"); + } catch (Exception ex) { + BaseView.takeScreenshot(editDocker + ".png"); + logger.info("Error :" + e.getMessage()); + fail(e.getMessage()); + } + } + + } + + @Then("^I verify \"([^\"]*)\" in the docker table$") + public void iVerifyInTheDockerTable(String dockerName) throws Throwable { + CreateEditDelDockerViews.verifyDocker(dockerName); + } + + @And("^I verify select organization is disabled in edit docker page$") + public void iVerifySelectOrganizationIsDisabledInEditDockerPage() throws Throwable { + CreateEditDelDockerViews.verifySelOrgIsDisabled(); + } + + @Then("^I verify \"([^\"]*)\" with \"([^\"]*)\" in the docker table$") + public void iVerifyWithInTheDockerTable(String dockerName, String dockerDetails) throws Throwable { + CreateEditDelDockerViews.verifyDockerInfo(dockerName,dockerDetails); + } + + @And("^I click on \"([^\"]*)\" link available$") + public void iClickOnLinkAvailable(String strChefServer) throws Throwable { + CreateEditDelDockerViews.clickonChefServer(strChefServer); + + } + + @And("^I click on \"([^\"]*)\" linktext$") + public void iClickOnLinktext(String strLinkName) throws Throwable { + CreateEditDelDockerViews.clickGallerySetuplink(strLinkName); + + + } + + @And("^I click on \"([^\"]*)\" linked$") + public void iClickOnLinked(String strTemplateLink) throws Throwable { + CreateEditDelDockerViews.clickTemplateLink(strTemplateLink); + + } + + + @And("^I add the cookbooks to runlist with \"([^\"]*)\"$") + public void iAddTheCookbooksToRunlistWith(String strCookbookValue) throws Throwable { + CreateEditDelDockerViews.addCookbooksRunlist(strCookbookValue); + + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelEnvSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelEnvSteps.java new file mode 100755 index 000000000..54fcd68d6 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelEnvSteps.java @@ -0,0 +1,136 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CreateEditDelEnvViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 26-07-2016. + */ +public class CreateEditDelEnvSteps { + + private static final Logger logger = Logger.getLogger(com.rl.qa.steps.LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I click on Environments link$") + public void iClickOnEnvironmentsLink() throws Throwable { + CreateEditDelEnvViews.clickOnEnvironmentsLink(); + } + + @And("^I click on \"([^\"]*)\" select Button and select one existing environment$") + public void iClickOnSelectButtonAndSelectOneExistingEnvironment(String serverName) throws Throwable { + CreateEditDelEnvViews.clickOnChefServerSelButton(serverName); + } + + @And("^I enter the \"([^\"]*)\" name in edit box$") + public void iEnterTheNameInEditBox(String chefEnvName) throws Throwable { + CreateEditDelEnvViews.enterChefEnvName(chefEnvName); + } + + @And("^I click on add chef environment button on create environment page$") + public void iClickOnAddChefEnvironmentButtonOnCreateEnvironmentPage() throws Throwable { + CreateEditDelEnvViews.clickOnAddChefEnvButtonOnEnvPage(); + + } + + @And("^I check \"([^\"]*)\" is disabled$") + public void iCheckIsDisabled(String idOfElement) throws Throwable { + CreateEditDelEnvViews.checkElementIsDisabled(idOfElement); + + } + + @And("^I enter chef environment in \"([^\"]*)\" Edit box$") + public void iEnterChefEnvironmentInEditBox(String idOfEditBox) throws Throwable { + CreateEditDelEnvViews.enterRandomEnvName(idOfEditBox); + } + + + @Then("^I verify created \"([^\"]*)\" in environments table$") + public void iVerifyCreatedEnvInEnvironmentsTable(String environmentName) throws Throwable { + CreateEditDelEnvViews.verifySelectedEnvNameFromChef(environmentName); + } + + + @Then("^I select the \"([^\"]*)\" and verify \"([^\"]*)\" Button is enabled in environments table$") + public void iSelectTheEnvAndVerifyButtonIsEnabledInEnvironmentsTable(String arg0, String Edit) throws Throwable { + CreateEditDelEnvViews.verifyEditIsEnabled(" ",Edit); + } + + @And("^I verify select chef server is disabled$") + public void iVerifySelectChefServerIsDisabled() throws Throwable { + CreateEditDelEnvViews.verifySelectChefServerisDisabled(); + } + + @Then("^I verify the created environment is deleted$") + public void iVerifyTheCreatedEnvironmentIsDeleted() throws Throwable { + CreateEditDelEnvViews.verifyEnvIsDeleted(); + } + + + @And("^I select existing chef \"([^\"]*)\" from chef server$") + public void iSelectExistingChefFromChefServer(String envName) throws Throwable { + CreateEditDelEnvViews.selectExistingEnv(envName); + + } + + @Then("^I verify \"([^\"]*)\" with assigned \"([^\"]*)\" in the environments table$") + public void iVerifyEnvWithAssignedOrgInTheEnvironmentsTable(String arg0, String org) throws Throwable { + CreateEditDelEnvViews.verifyAssignedOrgName(arg0,org); + } + + @And("^I verify created \"([^\"]*)\" in workzone$") + public void iVerifyCreatedInWorkzone(String arg0) throws Throwable { + CreateEditDelEnvViews.verifyEnvInWorkZone(); + } + + @And("^I click on the environment$") + public void iClickOnTheEnvironment() throws Throwable { + CreateEditDelEnvViews.clickOnEnv(); + } + + @And("^I select the \"([^\"]*)\" to be assigned with Env$") + public void iSelectTheToBeAssignedWithEnv(String projectname) throws Throwable { + CreateEditDelEnvViews.assigntheProject(projectname); + } + + @And("^I verify created \"([^\"]*)\" in workzone and click on it$") + public void iVerifyCreatedInWorkzoneAndClickOnIt(String arg0) throws Throwable { + CreateEditDelEnvViews.verifyAndSelectCreatedEnv(); + } + + @Then("^I verify \"([^\"]*)\" with \"([^\"]*)\" in the environments table$") + public void iVerifyWithInTheEnvironmentsTable(String environmentName, String org) throws Throwable { + CreateEditDelEnvViews.verifyAssignedDetailsOfEnv(environmentName,org); + } + + @Then("^I verify newly created \"([^\"]*)\" in environments table$") + public void iVerifyNewlyCreatedInEnvironmentsTable(String arg0) throws Throwable { + CreateEditDelEnvViews.verifyEnvName(); + } + + @Then("^I Verify \"([^\"]*)\" page is displayed$") + public void iVerifyPageIsDisplayed(String pageName) throws Throwable { + CreateEditDelEnvViews.verifyEditPageIsDisplayed(pageName); + } + + @And("^I click on \"([^\"]*)\" button on the \"([^\"]*)\" popup$") + public void iClickOnButtonOnThePopup(String arg0, String arg1) throws Throwable { + CreateEditDelEnvViews.clickOnAddButton(); + } + + @And("^I select environment from drop down$") + public void iSelectEnvironmentFromDropDown() throws Throwable { + CreateEditDelEnvViews.selectNewlyAddedEnv(); + } + + @Then("^I verify the created \"([^\"]*)\" is deleted$") + public void iVerifyTheCreatedIsDeleted(String envName) throws Throwable { + CreateEditDelEnvViews.verifyEnvironmentIsDeleted(envName); + + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelJenkinsSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelJenkinsSteps.java new file mode 100755 index 000000000..c83b986b5 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelJenkinsSteps.java @@ -0,0 +1,36 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CreateEditDelJenkinsViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 01-08-2016. + */ +public class CreateEditDelJenkinsSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + + @And("^I enter \"([^\"]*)\" in \"([^\"]*)\" Edit box$") + public void iEnterOrganizationNameInEditBox(String nameOfJenkins, String idOfEditBox) throws Throwable { + CreateEditDelJenkinsViews.enterJenkinsName(nameOfJenkins,idOfEditBox); + + } + + @Then("^I verify \"([^\"]*)\" in the jenkins table$") + public void iVerifyInTheJenkinsTable(String jenkinsPara) throws Throwable { + CreateEditDelJenkinsViews.verifyJenkins(jenkinsPara); + } + + + @Then("^I verify \"([^\"]*)\" with \"([^\"]*)\" in the jenkins table$") + public void iVerifyWithInTheJenkinsTable(String jenkinsRefName, String jenkinsPara) throws Throwable { + CreateEditDelJenkinsViews.verifyJenkinsDetails(jenkinsRefName,jenkinsPara); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelOrgSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelOrgSteps.java new file mode 100755 index 000000000..e06f8ec04 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelOrgSteps.java @@ -0,0 +1,137 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CreateEditDelJenkinsViews; +import com.rl.qa.views.CreateEditDelOrgViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 18-07-2016. + */ +public class CreateEditDelOrgSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I click on the Settings Link$") + public void iClickOnTheSettingsLink() throws Throwable { + CreateEditDelOrgViews.clickOnSettings(); + } + @And("^I click on Organizations link in main page$") + public void iClickOnOrganizationsLinkInMainPage() throws Throwable { + CreateEditDelOrgViews.clickOnOrganizations(); + } + + @And("^I click on \"([^\"]*)\" button$") + public void iClickOnButton(String newButtonId) throws Throwable { + CreateEditDelOrgViews.clickOnNewButton(newButtonId); + } + + @And("^I click on save button$") + public void iClickOnSaveButton() throws Throwable { + CreateEditDelOrgViews.saveOrg(); + } + + @And("^I clear the existing \"([^\"]*)\" in the edit box$") + public void iClearTheExistingInTheEditBox(String idOfEditbox) throws Throwable { + CreateEditDelOrgViews.clearTheField(idOfEditbox); + } + + @And("^I click on \"([^\"]*)\" delete button$") + public void iClickOnDeleteButton(String New_Organization) throws Throwable { + + CreateEditDelOrgViews.delOrg(New_Organization); + } + + @And("^I click on OK button$") + public void iClickOnOKButton() throws Throwable { + CreateEditDelOrgViews.clickOnOK(); + } + + + @And("^I click on the Settings Link when control is on organization page$") + public void iClickOnTheSettingsLinkWhenControlIsOnOrganizationPage() throws Throwable { + CreateEditDelOrgViews.clickOnSettingsFromOrgPage(); + } + + @Then("^I verify the created \"([^\"]*)\" in organization table$") + public void iVerifyTheCreatedOrgInOrganizationTable(String organizationName) throws Throwable { + CreateEditDelOrgViews.verifyCreatedOrg(organizationName); + } + + @And("^I see the catalyst \"([^\"]*)\"$") + public void iSeeTheCatalyst(String idOfElement) throws Throwable { + CreateEditDelOrgViews.seeWorkzone(idOfElement); + } + + @And("^I verify the edited \"([^\"]*)\" in list$") + public void iVerifyTheEditedInList(String editedOrg) throws Throwable { + CreateEditDelOrgViews.verifyEditedOrg(editedOrg); + } + + @Then("^I verify login page is displayed$") + public void iVerifyLoginPageIsDisplayed() throws Throwable { + CreateEditDelOrgViews.verifyLoginPage(); + } + + @Then("^I verify the \"([^\"]*)\" is deleted$") + public void iVerifyTheOrgIsDeleted(String orgName) throws Throwable { + CreateEditDelOrgViews.verifyDeletedOrg(orgName); + } + + @Then("^I verify \"([^\"]*)\" with \"([^\"]*)\" in the organization table$") + public void iVerifyWithInTheOrganizationTable(String domainName, String orgName) throws Throwable { + CreateEditDelOrgViews.verifyDomainName(domainName,orgName); + } + + @Then("^I verify \"([^\"]*)\" status with \"([^\"]*)\" in the organization table$") + public void iVerifyStatusWithInTheOrganizationTable(String status, String orgName) throws Throwable { + CreateEditDelOrgViews.verifyStatusOfOrg(status,orgName); + } + + @And("^I click on Current Status Button$") + public void iClickOnCurrentStatusButton() throws Throwable { + CreateEditDelOrgViews.clickOnStatusButton(); + } + + @And("^I select \"([^\"]*)\" in the show drop down$") + public void iSelectInTheShowDropDown(String expectedValFromDropdown) throws Throwable { + CreateEditDelOrgViews.selectAllInShowDropDown(expectedValFromDropdown); + } + + @And("^I click on OK button on Alert popup$") + public void iClickOnOKButtonOnAlertPopup() throws Throwable { + CreateEditDelOrgViews.clickOnOkOnAlertPopUp(); + } + + @And("^I enter the another \"([^\"]*)\" name$") + public void iEnterTheAnotherName(String New_Organization) throws Throwable { + CreateEditDelOrgViews.enterNewOrgName(New_Organization); + } + + @And("^I enter another \"([^\"]*)\" in \"([^\"]*)\" Edit box$") + public void iEnterAnotherInEditBox(String name, String idOfEditBox) throws Throwable { + CreateEditDelJenkinsViews.enterJenkinsName(name,idOfEditBox); + + } + + @And("^I close the toast popup$") + public void iCloseTheToastPopup() throws Throwable { + CreateEditDelOrgViews.clickOnCloseToast(); + } + + @And("^I move the cursor on \"([^\"]*)\"$") + public void iMoveTheCursorOn(String arg0) throws Throwable { + CreateEditDelOrgViews.moveCursorOnMenu(); + } + + @And("^I Check where application is landing and take the step$") + public void iCheckWhereApplicationIsLandingAndTakeTheStep() throws Throwable { + CreateEditDelOrgViews.checkAndDecide(); + + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelProjectSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelProjectSteps.java new file mode 100755 index 000000000..ded434bb6 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDelProjectSteps.java @@ -0,0 +1,70 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CreateEditDelProjectViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 20-07-2016. + */ +public class CreateEditDelProjectSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I click on Projects link$") + public void iClickOnProjectsLink() throws Throwable { + CreateEditDelProjectViews.clickOnProLink(); + } + + @And("^I click on new Projects button$") + public void iClickOnNewProjectsButton() throws Throwable { + CreateEditDelProjectViews.clickOnNewProButton(); + } + + + @And("^I click on \"([^\"]*)\"$") + public void iClickOn(String proOrg) throws Throwable { + CreateEditDelProjectViews.clickOnOrg(proOrg); + } + + @And("^I clear the project name field$") + public void iClearTheProjectNameField() throws Throwable { + CreateEditDelProjectViews.clearProNameField(); + } + + + @And("^I enter \"([^\"]*)\" name$") + public void iEnterName(String newProName) throws Throwable { + CreateEditDelProjectViews.typeNewProj(newProName); + } + + @And("^I click on \"([^\"]*)\" delete project button$") + public void iClickOnDeleteProjectButton(String proName) throws Throwable { + CreateEditDelProjectViews.delProject(proName); + } + + @Then("^I verify the created \"([^\"]*)\" in project table$") + public void iVerifyTheCreatedProInProjectTable(String proName) throws Throwable { + CreateEditDelProjectViews.verifyCreatedProject(proName); + } + + @Then("^I verify the \"([^\"]*)\" is deleted from project table$") + public void iVerifyTheIsDeletedFromProjectTable(String proName) throws Throwable { + CreateEditDelProjectViews.verifyDeletedPro(proName); + } + + @And("^I check the environment$") + public void iCheckTheEnvironment() throws Throwable { + CreateEditDelProjectViews.clickOnEnv(); + } + + @Then("^I verify the \"([^\"]*)\" with assigned \"([^\"]*)\" in project table$") + public void iVerifyTheWithAssignedInProjectTable(String projectName, String projectDetails) throws Throwable { + CreateEditDelProjectViews.verifyProjectInfo(projectName,projectDetails); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDeleteTeamSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDeleteTeamSteps.java new file mode 100755 index 000000000..64ec9d535 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/CreateEditDeleteTeamSteps.java @@ -0,0 +1,43 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.CreateEditDeleteTeamViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 16-08-2016. + */ +public class CreateEditDeleteTeamSteps { + private static final Logger logger = Logger.getLogger(com.rl.qa.steps.LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @Then("^I verify created \"([^\"]*)\" in the teams table$") + public void iVerifyCreatedInTheTeamsTable(String teamName) throws Throwable { + CreateEditDeleteTeamViews.verifyTeamName(teamName); + } + + @Then("^I verify created \"([^\"]*)\" with \"([^\"]*)\" in the teams table$") + public void iVerifyCreatedWithInTheTeamsTable(String teamName, String TeamDetails)throws Throwable { + CreateEditDeleteTeamViews.verifyTeamDetails(teamName,TeamDetails); + } + + @And("^I check the \"([^\"]*)\" check box$") + public void iCheckTheCheckBox(String value) throws Throwable { + CreateEditDeleteTeamViews.checkTheCheckBox(value); + } + + @And("^I find the \"([^\"]*)\" by navigating to different page in and click on corresponding \"([^\"]*)\" Button$") + public void iFindTheByNavigatingToDifferentPageInAndClickOnCorrespondingButton(String teamName, String edit) throws Throwable { + CreateEditDeleteTeamViews.searchAndEditTheTeam(teamName,edit); + } + + @Then("^I verify the \"([^\"]*)\" is deleted by navigating to different pages$") + public void iVerifyTheIsDeletedByNavigatingToDifferentPages(String teamName) throws Throwable { + CreateEditDeleteTeamViews.verifyTeamIsDeleted(teamName); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ImportNodeFromChefSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ImportNodeFromChefSteps.java new file mode 100755 index 000000000..c62c63e10 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ImportNodeFromChefSteps.java @@ -0,0 +1,154 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.ImportNodesFromChefViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 10-08-2016. + */ +public class ImportNodeFromChefSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + + @And("^I click on AWS provider$") + public void iClickOnAWSProvider() throws Throwable { + ImportNodesFromChefViews.clickOnAWSProvider(); + } + + @And("^I select type of blueprint \"([^\"]*)\"$") + public void iSelectTypeOfBlueprint(String blueprintType) throws Throwable { + ImportNodesFromChefViews.selectBlueprintType(blueprintType); + } + + @And("^I click on next button$") + public void iClickOnNextButton() throws Throwable { + ImportNodesFromChefViews.clickOnNext(); + } + + @And("^I select \"([^\"]*)\" in \"([^\"]*)\" select box$") + public void iSelectInSelectBox(String valueToSelect, String idOfSelectBox) throws Throwable { + ImportNodesFromChefViews.selectValues(valueToSelect,idOfSelectBox); + } + + @And("^I select \"([^\"]*)\" in select box$") + public void iSelectInSelectBox(String region) throws Throwable { + ImportNodesFromChefViews.selectRegion(region); + } + + @And("^I select security group$") + public void iSelectSecurityGroup() throws Throwable { + ImportNodesFromChefViews.selectSecurityGrp(); + } + + @And("^I click on the \"([^\"]*)\"$") + public void iClickOnThe(String tempName) throws Throwable { + ImportNodesFromChefViews.selectTemplate(tempName); + } + + @And("^I verify the \"([^\"]*)\" in the workzone$") + public void iVerifyTheInTheWorkzone(String envDetails) throws Throwable { + ImportNodesFromChefViews.verifyEnvDetails(envDetails); + } + + @And("^I click on launch blueprint$") + public void iClickOnLaunchBlueprint() throws Throwable { + ImportNodesFromChefViews.clickOnLaunchBlueprint(); + } + + @And("^I click on Workzone$") + public void iClickOnWorkzone() throws Throwable { + ImportNodesFromChefViews.clickOnWorkzone(); + } + + @And("^I click on launch blueprint on the pop-up menu$") + public void iClickOnLaunchBlueprintOnThePopUpMenu() throws Throwable { + ImportNodesFromChefViews.clickOnLaunchBlueprintPopUp(); + } + + @And("^I click on launch on select blueprint parameter pop-up menu$") + public void iClickOnLaunhOnSelectBlueprintParameterPopUpMenu() throws Throwable { + ImportNodesFromChefViews.clickOnLaunchOnSelBlueprintPopUp(); + } + + @And("^I capture the AWS ID of \"([^\"]*)\"$") + public void iCaptureTheAWSIDOf(String bluePrintName) throws Throwable { + ImportNodesFromChefViews.captureAwsId(bluePrintName); + } + + @And("^I capture the IP Address of \"([^\"]*)\"$") + public void iCaptureTheIPAddressOf(String bluePrintName) throws Throwable { + ImportNodesFromChefViews.captureIpAddress(bluePrintName); + } + + @And("^I click on Import Nodes button$") + public void iClickOnImportNodesButton() throws Throwable { + ImportNodesFromChefViews.clickOnImportNodesButton(); + } + + @And("^I enter \"([^\"]*)\" in \"([^\"]*)\" Edit box in Import Nodes popup window$") + public void iEnterInEditBoxInImportNodesPopupWindow(String userName, String idOfEditBox) throws Throwable { + ImportNodesFromChefViews.enterUserNameInPopup(userName,idOfEditBox); + } + @And("^I enter \"([^\"]*)\" in the search box and check the corresponding AWS ID checkbox$") + public void iEnterInTheSearchBoxAndCheckTheCorrespondingAWSIDCheckbox(String arg0) throws Throwable { + ImportNodesFromChefViews.checkTheCheckBoxOfCorrespondingAWSID(); + } + + @And("^I select \"([^\"]*)\" in \"([^\"]*)\" drop down in Import Nodes popup window$") + public void iSelectInDropDownInImportNodesPopupWindow(String BusinessGroup, String idOfDropDown) throws Throwable { + ImportNodesFromChefViews.selectBGroupInImportPopUp(BusinessGroup,idOfDropDown); + } + + @And("^I browse pem file in Import Nodes popup window$") + public void iBrowsePemFileInImportNodesPopupWindow() throws Throwable { + ImportNodesFromChefViews.importPemFileInPopupWindow(); + } + + @And("^I click on Import button on the popup window$") + public void iClickOnImportButtonOnThePopupWindow() throws Throwable { + ImportNodesFromChefViews.clickOnImportButton(); + } + + @And("^i verify Importing Nodes popup window is displayed$") + public void iVerifyImportingNodesPopupWindowIsDisplayed() throws Throwable { + ImportNodesFromChefViews.verifyImportingNodesPopUp(); + } + + @And("^I click on close button on popup window$") + public void iClickOnCloseButtonOnPopupWindow() throws Throwable { + ImportNodesFromChefViews.clickOnCloseButtonOnPopup(); + } + + @And("^I verify Node Imported with AWS ID$") + public void iVerifyNodeImportedWithAWSID() throws Throwable { + ImportNodesFromChefViews.verifyNodeImportedMessage(); + } + + @And("^I select the \"([^\"]*)\" from the drop down$") + public void iSelectTheFromTheDropDown(String envName) throws Throwable { + ImportNodesFromChefViews.selectEnv(envName); + + } + + @And("^I delete the launched instance from Instances$") + public void iDeleteTheLaunchedInstanceFromInstances() throws Throwable { + ImportNodesFromChefViews.deleteInstance(); + } + + @Then("^I verify \"([^\"]*)\" message on popup$") + public void iVerifyMessageOnPopup(String confirmationMsg) throws Throwable { + ImportNodesFromChefViews.verifyConfirmationMsg(confirmationMsg); + } + +// @And("^I browse pem file in Import Nodes popup window$") +// public void iBrowsePemFileInImportNodesPopupWindow() throws Throwable { +// ImportNodesFromChefViews.browsePemFile(); +// } +} \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/LoginSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/LoginSteps.java new file mode 100755 index 000000000..56f571753 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/LoginSteps.java @@ -0,0 +1,317 @@ +package com.rl.qa.steps; + + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.CucumberContext; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.LoginViews; +import cucumber.api.Scenario; +import cucumber.api.java.After; +import cucumber.api.java.Before; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Given; +import cucumber.api.java.en.Then; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TakesScreenshot; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.PageFactory; + +import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static com.rl.qa.utils.CucumberContext.getCucumberContext; +import static junit.framework.Assert.assertNotNull; + +/** + * Created by RLE0097 on 21-06-2016. + */ +public class LoginSteps { + private static WebDriver driver; + private static Scenario scenario; + + + + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @Then("^I Login to IWMS using \"([^\"]*)\" access credentials$") + public void I_Login_to_IWMS_using_access_credentials(String loginName) throws Throwable { + try { + boolean flag = false; + String strUserName, strPassword; + + strUserName = CucumberContext.getUserName(); + strPassword = CucumberContext.getPassword(); + + URL url = CucumberContext.getURL(); + + assertNotNull(url); + + String appURL = url.toString(); + + assertNotNull(appURL); + + // Load browser and point it at configured IWMS web-ui. + BrowserDriver.loadPage(appURL); + + Boolean loggedIn = (Boolean) getCucumberContext().get("loggedIn"); + if (loggedIn != null && loggedIn) { + logger.info("Already logged in, reusing authenticated session(1)."); + return; + } + + + logger.info("Logged in successfully."); +// } else +// logger.info("Login to IWMS using " + loginName + " access credentials does not exist in excel spreadsheet"); + } catch (Exception e) { + BaseView.takeScreenshot("I_Login_to_IWMS_using_access_credentials"); + String msg = String.format("Unable to login and see expected dashboard: %s", e.getMessage()); + logger.log(Level.SEVERE, msg, e); + logger.info("Created new WebDriver instance as old one was failing to respond."); +// fail(msg); + } + } + + @Given("^I Login to catalyst using \"([^\"]*)\" access credentials$") + public void I_Login_to_catalyst_using_access_credentials(String loginName,String password) throws Throwable { + try { + boolean flag = false; + String strUserName, strPassword; + + + strUserName = loginName;//CucumberContext.getUserName(); + strPassword = password;//CucumberContext.getPassword(); + + + URL url = CucumberContext.getURL(); + + assertNotNull(url); + + String appURL = url.toString(); + + assertNotNull(appURL); + + // Load browser and point it at configured IWMS web-ui. + BrowserDriver.loadPage(appURL); + + LoginViews.enterUsername(strUserName); + LoginViews.enterPassword(strPassword); + LoginViews.clickLoginButton(); + + /*Boolean loggedIn = (Boolean) getCucumberContext().get("loggedIn"); + if (loggedIn != null && loggedIn) { + logger.info("Already logged in, reusing authenticated session(1)."); + return; + }*/ + + + logger.info("Logged in successfully."); + } catch (Exception e) { + BaseView.takeScreenshot("I_Login" + loginName + "_using_access_credentials"); + String msg = String.format("Unable to login and see expected dashboard: %s", e.getMessage()); + logger.log(Level.SEVERE, msg, e); + logger.info("Created new WebDriver instance as old one was failing to respond."); + } + } + + @Given("^I Login to created new stack using \"([^\"]*)\" access credentials$") + public void I_Login_to_created_new_stack_using_access_credentials(String loginName) throws Throwable { + try { + boolean flag = false; + String strUserName, strPassword; + + strUserName = "superadmin";//CucumberContext.getUserName(); + strPassword = "superadmin@123";//CucumberContext.getPassword(); + + URL url = CucumberContext.getURL(); + + assertNotNull(url); + + String appURL = url.toString(); + + assertNotNull(appURL); + + // Load browser and point it at configured IWMS web-ui. + BrowserDriver.loadPage(appURL); + + LoginViews.enterUsername(strUserName); + LoginViews.enterPassword(strPassword); + LoginViews.clickLoginButton(); + + Boolean loggedIn = (Boolean) getCucumberContext().get("loggedIn"); + if (loggedIn != null && loggedIn) { + logger.info("Already logged in, reusing authenticated session(1)."); + return; + } + + + logger.info("Logged in successfully."); + } catch (Exception e) { + BaseView.takeScreenshot("I_Login" + loginName + "_using_access_credentials"); + String msg = String.format("Unable to login and see expected dashboard: %s", e.getMessage()); + logger.log(Level.SEVERE, msg, e); + logger.info("Created new WebDriver instance as old one was failing to respond."); + } + } + + @Given("^I Login to created new stack \"([^\"]*)\" using \"([^\"]*)\" access credentials$") + public void I_Login_to_created_new_stack_using_access_credentials(String strStackName, String strLoginName) throws Throwable { + try { + Thread.sleep(200000); + boolean flag = false; + String strUserName, strPassword; + + strUserName = strLoginName;//CucumberContext.getUserName(); + strPassword = "superadmin@123";//CucumberContext.getPassword(); + +// URL url = strStackName+"."+"rlcatalyst.com"; CucumberContext.getURL(); + String url = "http://" + strStackName + ".rlcatalyst.com"; + assertNotNull(url); + + String appURL = url.toString(); + + assertNotNull(appURL); + + // Load browser and point it at configured IWMS web-ui. + BrowserDriver.loadPage(appURL); + + LoginViews.enterUsername(strUserName); + LoginViews.enterPassword(strPassword); + LoginViews.clickLoginButton(); + + Boolean loggedIn = (Boolean) getCucumberContext().get("loggedIn"); + if (loggedIn != null && loggedIn) { + logger.info("Already logged in, reusing authenticated session(1)."); + return; + } + + + logger.info("Logged in successfully."); + } catch (Exception e) { + BaseView.takeScreenshot("I_Login" + strLoginName + "_using_access_credentials"); + String msg = String.format("Unable to login and see expected dashboard: %s", e.getMessage()); + logger.log(Level.SEVERE, msg, e); + logger.info("Created new WebDriver instance as old one was failing to respond."); + } + } + + @And("^I Sign Out$") + public void I_Sign_Out() throws Throwable { + LoginViews.signOut(); + } + + + @Before + public static void setUp(Scenario scenario) { + scenario = scenario; + System.out.println("I am at before"); + + } + + @After + public static void embedscreenshot(Scenario scenario) { + + if (scenario.isFailed()) { + try { + //encoded_img = @browser.driver.screenshot_as(:base64) + byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); + scenario.embed(screenshot, "image/png"); //stick it in the report + System.out.println("I am at after"); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + } + + + + @Given("^I need to check for which mail\"([^\"]*)\" application to login with valid credentials$") + public void iNeedToCheckForWhichMailApplicationToLoginWithValidCredentials(String strEmailAppName) throws Throwable { + LoginViews.whichApplicationToLaunch(strEmailAppName); + + } + + @Given("^I Login to catalyst using \"([^\"]*)\" and \"([^\"]*)\" and \"([^\"]*)\"access credentials$") + public void iLoginToCatalystUsingAndAndAccessCredentials(String strAppUrl, String loginName, String password) throws Throwable { + try { + boolean flag = false; + String strUserName, strPassword; + + + strUserName = loginName;//CucumberContext.getUserName(); + strPassword = password;//CucumberContext.getPassword(); + + + //URL url = CucumberContext.getURL(); + + //assertNotNull(url); + + //String appURL = url.toString(); + + //assertNotNull(appURL); + + // Load browser and point it at configured IWMS web-ui. + + if(strAppUrl.contains("gmail")) { + BrowserDriver.loadPage(strAppUrl); + LoginViews.enterUsername(strUserName); + LoginViews.enterPassword(strPassword); + LoginViews.clickLoginButton(); + LoginViews.signOutGmail(); + } + else if (strAppUrl.contains("yahoo")){ + BrowserDriver.loadPage(strAppUrl); + LoginViews.enterYahooUsername(strUserName); + LoginViews.enterYahooPassword(strPassword); + LoginViews.clickYahooLoginButton(); + LoginViews.signOutYahoo(); + + } + else + { + System.out.println("Your option is not Gmail or Yahoo"); + + //if (strAppUrl.contains("rediff")){ + // BrowserDriver.loadPage(strAppUrl); + //LoginViews.enterUsername(strUserName); + //LoginViews.enterPassword(strPassword); + //LoginViews.clickLoginButton(); + } + + + /*Boolean loggedIn = (Boolean) getCucumberContext().get("loggedIn"); + if (loggedIn != null && loggedIn) { + logger.info("Already logged in, reusing authenticated session(1)."); + return; + }*/ + + + logger.info("Logged in successfully."); + } catch (Exception e) { + BaseView.takeScreenshot("I_Login" + loginName + "_using_access_credentials"); + String msg = String.format("Unable to login and see expected dashboard: %s", e.getMessage()); + logger.log(Level.SEVERE, msg, e); + logger.info("Created new WebDriver instance as old one was failing to respond."); + } + } + + + @Then("^I logout of the Application$") + public void iLogoutOfTheApplication() throws Throwable { + + } + + @Then("^I logged out of application successfully$") + public void iLoggedOutOfApplicationSuccessfully() throws Throwable { + LoginViews.loggedout(); + } +} + + + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ProivderSyncSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ProivderSyncSteps.java new file mode 100755 index 000000000..c217a8ac0 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/ProivderSyncSteps.java @@ -0,0 +1,39 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import cucumber.api.PendingException; +import cucumber.api.java.en.And; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by rle0346 on 11/8/16. + */ +public class ProivderSyncSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I Click on Teams Link$") + public void iClickOnTeamsLink() throws Throwable { + + } + + + @And("^Clicks on New Team Button$") + public void clicksOnNewTeamButton() throws Throwable { + + } + + + @And("^Enters the Team Name$") + public void entersTheTeamName() throws Throwable { + + } + + @And("^Enters the Team Description$") + public void entersTheTeamDescription() throws Throwable { + + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/TemplateSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/TemplateSteps.java new file mode 100755 index 000000000..ed31f0915 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/TemplateSteps.java @@ -0,0 +1,59 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.TemplateViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 11-08-2016. + */ +public class TemplateSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I click On \"([^\"]*)\" link$") + public void iClickOnLink(String linkText) throws Throwable { + TemplateViews.clickOnLink(linkText); + + } + + @And("^I select \"([^\"]*)\" from select box$") + public void iSelectFromSelectBox(String tempType) throws Throwable { + TemplateViews.selectTempType(tempType); + } + + @Then("^I verify the \"([^\"]*)\" is deleted from the Templates table$") + public void iVerifyTheIsDeletedFromTheTemplatesTable(String tempName) throws Throwable { + TemplateViews.verifyDeletedTemp(tempName); + } + + @And("^I verify \"([^\"]*)\" is displayed$") + public void iVerifyIsDisplayed(String idOfChkBox) throws Throwable { + TemplateViews.verifyChefFactory(idOfChkBox); + } + + @Then("^I select \"([^\"]*)\" and verify corresponding \"([^\"]*)\" in Templates table$") + public void iSelectAndVerifycorrespondingCreatedInTemplatesTable(String templateName, String tempDetails) throws Throwable { + TemplateViews.verifyTempDetails(templateName,tempDetails); + } + + @Then("^I verify \"([^\"]*)\" is available in templates table$") + public void iVerifyIsAvailableInTemplatesTable(String tempName) throws Throwable { + TemplateViews.verifyTempName(tempName); + } + + @And("^I browse \"([^\"]*)\" Template file$") + public void iBrowseTemplateFile(String fileName) throws Throwable { + TemplateViews.browseAndUploadTemplateFile(fileName); + } + + @And("^I select \"([^\"]*)\" from the drop down in create template page$") + public void iSelectFromTheDropDownInCreateTemplatePage(String orgName) throws Throwable { + TemplateViews.selectOrgInTemplatePage(orgName); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/VMImageSteps.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/VMImageSteps.java new file mode 100755 index 000000000..96867a374 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/steps/VMImageSteps.java @@ -0,0 +1,43 @@ +package com.rl.qa.steps; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.SeleniumUtilities; +import com.rl.qa.views.VMImageViews; +import cucumber.api.java.en.And; +import cucumber.api.java.en.Then; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +/** + * Created by RLE0372 on 11-08-2016. + */ +public class VMImageSteps { + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + private static final com.rl.qa.utils.SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + @And("^I select \"([^\"]*)\" type$") + public void iSelectOSType(String osType) throws Throwable { + VMImageViews.selectOS(osType); + } + + @Then("^I verify created \"([^\"]*)\" in the Images table$") + public void iVerifyCreatedInTheImagesTable(String imageName) throws Throwable { + VMImageViews.verifyCreatedImage(imageName); + } + + @Then("^I select \"([^\"]*)\" and verify assigned \"([^\"]*)\" in Images table$") + public void iSelectAndVerifyAssignedInImagesTable(String imageName, String imageDetail ) throws Throwable { + VMImageViews.verifyVMImageDetails(imageName,imageDetail); + } + + @Then("^I select \"([^\"]*)\" and verify given \"([^\"]*)\" in Images table$") + public void iSelectAndVerifyGivenInImagesTable(String imageName, String imageDetail) throws Throwable { + VMImageViews.verifyImageId(imageName,imageDetail); + } + + @And("^I select \"([^\"]*)\" from the select box in VMImage page$") + public void iSelectFromTheSelectBoxInVMImagePage(String orgName) throws Throwable { + VMImageViews.selectOrgInVMImagePage(orgName); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/AjaxEnabledPageFactory.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/AjaxEnabledPageFactory.java new file mode 100755 index 000000000..c1515cbe7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/AjaxEnabledPageFactory.java @@ -0,0 +1,54 @@ +package com.rl.qa.utils; + +import org.apache.commons.lang3.StringUtils; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory; +import org.openqa.selenium.support.pagefactory.ElementLocatorFactory; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class AjaxEnabledPageFactory extends PageFactory { + static Method instantiatePageMethod = null; + + static { + Method[] methods = PageFactory.class.getDeclaredMethods(); + for (Method method : methods) { + if (StringUtils.equals(method.getName(), "instantiatePage")) { + instantiatePageMethod = method; + instantiatePageMethod.setAccessible(true); + } + } + } + + public static T ajaxInitElements(WebDriver driver, Class pageClassToProxy) { + T page = instantiatePage(driver, pageClassToProxy); + initElements(driver, page); + return page; + } + + public static void initElements(WebDriver driver, Object page) { + final WebDriver driverRef = driver; + initElements(new AjaxElementLocatorFactory(driverRef, 10), page); + } + public static void initElements(ElementLocatorFactory factory, Object page) { + final ElementLocatorFactory factoryRef = factory; + initElements(new StaleReferenceAwareFieldDecorator(factoryRef, 3), page); + } + + protected static T instantiatePage(WebDriver driver, + Class pageClassToProxy) { + try { + return (T) instantiatePageMethod.invoke( + AjaxEnabledPageFactory.class, driver, pageClassToProxy); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/BaseView.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/BaseView.java new file mode 100755 index 000000000..a16d303b8 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/BaseView.java @@ -0,0 +1,339 @@ +package com.rl.qa.utils; + +import com.google.common.collect.Iterables; +import com.rl.qa.FileUtilities; +import com.rl.qa.browsers.BrowserDriver; +import cucumber.api.java.After; +import cucumber.api.java.Before; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.openqa.selenium.*; +import org.openqa.selenium.support.ui.Select; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +import static junit.framework.Assert.fail; + +public class BaseView { + + private static final Logger logger = Logger.getLogger(BaseView.class.getName()); + private final static int DEFAULT_TIMEOUT = 40; + public static String mainWindowHandle; + public static String genericSecondWindowHandle; + + + public static void pushShortTimeout() { + BrowserDriver.getCurrentDriver().manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); + } + + public static void pushShortTimeout(int intSeconds) { + BrowserDriver.getCurrentDriver().manage().timeouts().implicitlyWait(intSeconds, TimeUnit.SECONDS); + } + + public static void pushMillSecTimeout(int millSec) { + BrowserDriver.getCurrentDriver().manage().timeouts().implicitlyWait(millSec, TimeUnit.MILLISECONDS); + } + + public static void pushVeryShortTimeout() { + BrowserDriver.getCurrentDriver().manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); + } + + public static void popDefaultTimeout() { + BrowserDriver.getCurrentDriver().manage().timeouts().implicitlyWait(DEFAULT_TIMEOUT, TimeUnit.SECONDS); + } + + /** + * Returns true if the specified WebElement is visible, does not wait for + * the element. + */ + public static boolean isElementPresentNoWait(WebElement we) { + try { + pushShortTimeout(); + + return we.isDisplayed(); + } catch (NoSuchElementException e) { + return false; + } catch (NullPointerException e) { + return false; + } finally { + popDefaultTimeout(); + } + } + +// Waits for the max time mentioned or till the element is visible and then moves to the next step - rupi + public static WebElement waitForElement(By by) throws InterruptedException { + WebElement visible = null; + long maxTime = 15 * 100; // time in milliseconds + long waitTime = 350; + long elapsedTime = 0; + do { + try { + Thread.sleep(waitTime); + elapsedTime += waitTime; + visible = BrowserDriver.getCurrentDriver().findElement(by); + if (!visible.isDisplayed()) { + visible = null; + } else { + System.out.println("element visible" + by); + } + } catch (NoSuchElementException e) { + System.out.println("waiting for element to be visible"+ by); + } + } while (visible == null && elapsedTime < maxTime); + return visible; + } + +// Selects the dropdown by the label text + public static void selectFromList(By by, String visibleText) { + Select selectNew = new Select(BrowserDriver.getCurrentDriver().findElement(by)); + selectNew.selectByVisibleText(visibleText); + } + + // returns the selected value in the drop down + protected String getSelectedTextInDropDown(By by) { + Select sel = new Select(BrowserDriver.getCurrentDriver().findElement(by)); + return sel.getFirstSelectedOption().getText(); + } + + public static void clickLink(String linkText) { + try { + waitForElement(By.linkText(linkText)); + } catch (InterruptedException e) { + System.out.println("Could not find link text"); + } + BrowserDriver.getCurrentDriver().findElement(By.linkText(linkText)).click(); + } + + public static void switchToFrame()throws InterruptedException{ + waitForElement(By.tagName("iframe")); + String iframeID = BrowserDriver.getCurrentDriver().findElement(By.tagName("iframe")).getAttribute("id"); + BrowserDriver.getCurrentDriver().switchTo().frame(iframeID); + } + + //this method will find the right iframe containing specific CSS element and switch to it + public static void switchToFrameWithField(String cssSelector)throws InterruptedException{ + waitForElement(By.tagName("iframe")); + List iframeList = BrowserDriver.getCurrentDriver().findElements(By.tagName("iframe")); + List idList = new ArrayList(); + //just record the iframes IDs here + for (WebElement we : iframeList) { + String iframeID = we.getAttribute("id"); + idList.add(iframeID); + } + //have to do it in separate loop as selenium is real funny about object access + for (String id : idList) { + BrowserDriver.getCurrentDriver().switchTo().frame(id); + List itemList = BrowserDriver.getCurrentDriver().findElements(By.cssSelector(cssSelector)); + if (itemList.size() > 0) { + break; + } + //have to go back to default frame to find next child iframe + BrowserDriver.getCurrentDriver().switchTo().defaultContent(); + } + } + + public static void takeScreenshot(String filename) { + File dir = new File(FileUtilities.getCWD(), "//target//screenshots"); + dir.mkdirs(); + + SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy_hhmmss"); + Date curDate = new Date(); + String strDate = sdf.format(curDate); + filename = filename.replace(".png",""); + filename = filename + strDate+".png"; + + File file = new File(dir, filename); + + try { + BrowserDriver.takeScreenshot(file); + System.out.format("Wrote screen shot to '%s'", file.getAbsolutePath()); + } catch (IOException e) { + System.out.format("Unable to write screen shot to '%s': %s", file.getAbsolutePath(), e.getMessage()); + } + } + + public static void switchToFrameByTitle(String title)throws InterruptedException { + WebElement iframe = BrowserDriver.getCurrentDriver().findElement(By.cssSelector("iframe[title=\""+title+"\"]")); + BrowserDriver.getCurrentDriver().switchTo().frame( iframe ); + } + + public static void switchToSecondFrame() { + + WebElement secondIframe = null; + List iframes = BrowserDriver.getCurrentDriver() + .findElements(By.cssSelector("iframe")); + if(CollectionUtils.isNotEmpty(iframes)) { + + int i = 0; + for(WebElement iFrame : iframes) { + if(iFrame.getAttribute("title") != null && i++ == 1) { + secondIframe = iFrame; + break; + } + } + + if(secondIframe == null) { + fail("Couldn't find second iFrame"); + } + + BrowserDriver.getCurrentDriver().switchTo().frame( secondIframe ); + + } else { + fail("There are no iFrames found"); + } + + } + + /** + * Get's second window handle. + * Helpful when dealing with multiple windows + * + * @return + * @see BaseView#getCurrentWindowHandle() + */ + public static void switchToSecondWindow() { + /* try { + Thread.sleep(4000); + } catch (InterruptedException e) { + e.printStackTrace(); + }*/ +// Set windowHandles = BrowserDriver.getCurrentDriver().getWindowHandles(); +// if(CollectionUtils.isNotEmpty(windowHandles)) { +// mainWindowHandle = Iterables.get(windowHandles, 0, null); +// String secondWindowHandle = Iterables.get(windowHandles, 1, null); +// +// if(StringUtils.isNotEmpty(secondWindowHandle)) { +// BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle); +// BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle).manage().window().setPosition(new Point(0, 0)); +// BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle).manage().window().setSize(new Dimension(1500, 800)); +// } else { +// logger.warning("There is no second browser window found"); +// } +// } + for(int i=0;i<20;i++) { + Set windowHandles = BrowserDriver.getCurrentDriver().getWindowHandles(); + if (CollectionUtils.isNotEmpty(windowHandles)) { + mainWindowHandle = Iterables.get(windowHandles, 0, null); + String secondWindowHandle = Iterables.get(windowHandles, 1, null); + genericSecondWindowHandle = secondWindowHandle; + + if (StringUtils.isNotEmpty(secondWindowHandle)) { + BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle); + BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle).manage().window().setPosition(new Point(0, 0)); + BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle).manage().window().setSize(new Dimension(1500, 800)); + return; + } else { + /* try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + }*/ + logger.warning(i + " : There is no second browser window found"); + } + } + } + } + + + public boolean switchToSecondWindow(int counter) { + boolean flag = false; + for(int i=0;i windowHandles = BrowserDriver.getCurrentDriver().getWindowHandles(); + if (CollectionUtils.isNotEmpty(windowHandles)) { + mainWindowHandle = Iterables.get(windowHandles, 0, null); + String secondWindowHandle = Iterables.get(windowHandles, 1, null); + + if (StringUtils.isNotEmpty(secondWindowHandle)) { + BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle); + BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle).manage().window().setPosition(new Point(0, 0)); + BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle).manage().window().setSize(new Dimension(1500, 800)); + flag = true; + } else { + logger.warning("There is no second browser window found"); + } + } + } + return flag; + } + + public static void switchToSecondWindowToClose() { + /* try { + Thread.sleep(4000); + } catch (InterruptedException e) { + e.printStackTrace(); + }*/ + Set windowHandles = BrowserDriver.getCurrentDriver().getWindowHandles(); + if(CollectionUtils.isNotEmpty(windowHandles)) { + mainWindowHandle = Iterables.get(windowHandles, 0, null); + String secondWindowHandle = Iterables.get(windowHandles, 1, null); + + if(StringUtils.isNotEmpty(secondWindowHandle)) { + BrowserDriver.getCurrentDriver().switchTo().window(secondWindowHandle).close(); + } else { + logger.warning("There is no second browser window found"); + } + } + } + + public static void switchToThirdWindowToClose() { + /* try { + Thread.sleep(4000); + } catch (InterruptedException e) { + e.printStackTrace(); + }*/ + Set windowHandles = BrowserDriver.getCurrentDriver().getWindowHandles(); + if(CollectionUtils.isNotEmpty(windowHandles)) { + mainWindowHandle = Iterables.get(windowHandles, 0, null); + String thirdWindowHandle = Iterables.get(windowHandles, 2, null); + + if(StringUtils.isNotEmpty(thirdWindowHandle)) { + BrowserDriver.getCurrentDriver().switchTo().window(thirdWindowHandle).close(); + } else { + logger.warning("There is no second browser window found"); + } + } + } + + /** + * Get's current window handle. + * Helpful when dealing with multiple windows + * + * @return + * @see BaseView#switchToSecondWindow() + */ + public static String getCurrentWindowHandle() { + + return BrowserDriver.getCurrentDriver().getWindowHandle(); + } + + + public static void switchToThirdWindow() { + BrowserDriver.getCurrentDriver().switchTo().window(BaseView.mainWindowHandle); + for(int i=0;i<20;i++) { + Set windowHandles = BrowserDriver.getCurrentDriver().getWindowHandles(); + if (CollectionUtils.isNotEmpty(windowHandles)) { + mainWindowHandle = Iterables.get(windowHandles, 0, null); + String thirdWindowHandle = Iterables.get(windowHandles, 2, null); + + if (StringUtils.isNotEmpty(thirdWindowHandle)) { + BrowserDriver.getCurrentDriver().switchTo().window(thirdWindowHandle); + BrowserDriver.getCurrentDriver().switchTo().window(thirdWindowHandle).manage().window().setPosition(new Point(0, 0)); + BrowserDriver.getCurrentDriver().switchTo().window(thirdWindowHandle).manage().window().setSize(new Dimension(1500, 800)); + return; + } else { + logger.warning(i + " : There is no third browser window found"); + } + } + } + } + + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/CucumberContext.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/CucumberContext.java new file mode 100755 index 000000000..ffdbb6fb5 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/CucumberContext.java @@ -0,0 +1,434 @@ +package com.rl.qa.utils; + +import com.google.common.collect.ImmutableMap; +import com.rl.qa.browsers.BrowserType; +import org.apache.commons.lang.NotImplementedException; +import org.apache.http.auth.Credentials; +import org.junit.Assert; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Properties; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.google.common.base.Strings.isNullOrEmpty; +import static junit.framework.Assert.assertNotNull; +import static org.junit.Assert.fail; + +//import sun.reflect.generics.reflectiveObjects.NotImplementedException; + +/** + * Manages test execution context by providing properties that define: + * 1) IWMS url + * 2) IWMS authentication credentials + * 3) WEB Browser (e.g. Firefox) + * 4) Selenium HUB url if remote browser specified + * 5) Anything else a test case wants to share + * + * The property values originate from one of three sources: + * 1) Environment variables + * 2) JVM properties + * 3) Currently active maven profile + * + * The 1st place a given property is defined takes precedence over the other + * sources. + * + * The following is the set of properties that can be defined via the above + * mentioned three sources: + * + * Property Purpose Example + * ------------- ---------------- ---------------------------- + * browser Browser to use REMOTE_FIREFOX + * selenium.hub Selenium HUB url http://127.0.0.1:4444/wd/hub + * iwms.url IWMS web-ui url http://test.lucernex.com + * iwms.username IWMS username rootDev + * iwms.password IWMS password not-going-to-say + * iwms.firm IWMS firm name QA + * + * So for example if you wanted to override the firm name that is specified + * by the maven profile you could use this JVM execution argument: + * + * -Diwms.firm=whatever + * + * Note: if you specify one of the remote browsers (e.g. REMOTE_FIREFOX), then you + * must also provide a value for the selenium.hub property as that is where + * the remote browser is expected to be. + */ +public class CucumberContext extends HashMap { + private static final Logger logger = Logger.getLogger(CucumberContext.class.getName()); + + // The properties file that defines the IWMS url and credentials. + private static final String LX_SELENIUM_RESOURCE = "lx-selenium.properties"; + + // Map key for Credentials object. + public static final String CREDENTIALS = "credentials"; + + // Property name (JVM and environment variable) for Selenium HUB URL to use. + public static final String SELENIUM_HUB = "selenium.hub"; + + // Property name (JVM, environment variable, and lx-selenium.properties) for name of web-browser to use. + public static final String BROWSER = "browser"; + + // Property name (JVM, environment variable, and lx-selenium.properties) for URL of IWMS web-ui. + public static final String IWMS_URL = "iwms.url"; + + // Property name (JVM, environment variable, and lx-selenium.properties) for IWMS username. + public static final String IWMS_USERNAME = "iwms.username"; + + // Property name (JVM, environment variable, and lx-selenium.properties) for IWMS password. + public static final String IWMS_PASSWORD = "iwms.password"; + + // Property name (JVM, environment variable, and lx-selenium.properties) for IWMS firm. + public static final String IWMS_FIRM = "iwms.firm"; + + // Property name of member's DateFormat (cache of getSessionDateFormat() call). + public static String SESSION_DATE_FORMAT = "DateFormat"; + + // Property name of member's NumberFormat (cache of getSessionNumberFormat() call). + public static String SESSION_NUMBER_FORMAT = "NumberFormat"; + + // Property name of member's Locale (cache of getSessionNumberFormat() call). + public static String SESSION_LOCALE = "Locale"; + + private static final ThreadLocal cucumberThreadLocal = new ThreadLocal() { + protected CucumberContext initialValue() { + return new CucumberContext(); + } + }; + + public static URL getURL() { + return (URL)getCucumberContext().get(IWMS_URL); + } + + public static String getUserName() { + return (String)getCucumberContext().get(IWMS_USERNAME); + } + + public static String getPassword() { + return (String)getCucumberContext().get(IWMS_PASSWORD); + } + + private static URL handleURLProperty(String name, String value) { + // Assert.assertNotNull(String.format("Required property '%s' not specified", name), value); + + try { + URL url = new URL(value); + + getCucumberContext().put(name, url); + + return url; + } catch (MalformedURLException e) { + String msg2 = String.format( + "Property '%s' specifies an invalid URL '%s': %s", + name, + value, + e.getMessage() + ); + + fail(msg2); + + return null; // will never happen due to fail() call above. + } + } + + private static void handleBrowserProperty(String value) { + Assert.assertNotNull("Required property 'browser' not specified", value); + + BrowserType browserType; + + try { + browserType = BrowserType.fromString(value); + } catch (IllegalArgumentException e) { + browserType = BrowserType.FIREFOX; + } + + getCucumberContext().put(BROWSER, browserType); + } + + /** + * Returns the value of the specified property by consulting three sources: + * Environment, JVM Property, and maven props in that order (1st one wins). + * + * @param props - properties as supplied by current maven profile (can be null) + * @param name - name of desired property + */ + private static String getPropertyValue(Properties props, String name) { + String value = System.getenv(name); + + if (!isNullOrEmpty(value)) { + logger.info(String.format("Property [%s] value [%s] set by environment variable", name, value)); + return value; + } + + value = System.getProperty(name); + + if (!isNullOrEmpty(value)) { + logger.info(String.format("Property [%s] value [%s] set by system property", name, value)); + return value; + } + + if (props != null) { + value = props.getProperty(name); + if (!name.equals("iwms.password") || value.startsWith("DES:")) { + logger.info(String.format("Property [%s] value [%s] set by maven profile", name, value)); + } + } + + return value; + } + + /** + * Returns the value of the specified property by consulting two sources: + * Environment and JVM Property in that order (1st one wins). + * + * @param name - name of desired property + */ + private static String getPropertyValue(String name) { + return getPropertyValue(null, name); + } + + /** + * Lazy load the properties as defined by the 'lx-selenium.properties' file + * with optional JVM overrides. + */ +// private static void loadIWMSProperties() { +// if (getCucumberContext().get(IWMS_URL) == null) { +// InputStream in = "";//Credentials.class.getClassLoader().getResourceAsStream(LX_SELENIUM_RESOURCE); +// +// assertNotNull("Resource '" + LX_SELENIUM_RESOURCE + "' not found in classpath!", in); +// +// try { +// Properties props = new Properties(); +// String username = null; +// String password = null; +// String firmname = null; +// +// props.load(in); +// +// for (Object key : props.keySet()) { +// String name = (String)key; +// +// if (IWMS_URL.equals(name)) { +// handleURLProperty(name, getPropertyValue(props, IWMS_URL)); +// } else if (BROWSER.equals(name)) { +// handleBrowserProperty(getPropertyValue(props, BROWSER)); +// } else if (IWMS_USERNAME.equals(name)) { +// username = getPropertyValue(props, IWMS_USERNAME); +// } else if (IWMS_PASSWORD.equals(name)) { +// password = getPropertyValue(props, IWMS_PASSWORD); +// } else if (IWMS_FIRM.equals(name)) { +// firmname = getPropertyValue(props, IWMS_FIRM); +// } else { +// logger.warning(String.format("Ignoring unexpected property '%s'", name)); +// } +// } +// +// Assert.assertNotNull( +// String.format("Required property '%s' not defined!", IWMS_USERNAME), +// username +// ); +// Assert.assertNotNull( +// String.format("Required property '%s' not defined!", IWMS_PASSWORD), +// password +// ); +// Assert.assertNotNull( +// String.format("Required property '%s' not defined!", IWMS_FIRM), +// firmname +// ); +// +// handleCredentials(username, password, firmname); +// try { +// SESSION_LOCALE=getLocaleByUserName(username, "Language"); +// SESSION_NUMBER_FORMAT=getLocaleByUserName(username, "NumberPattern"); +// SESSION_DATE_FORMAT=getLocaleByUserName(username, "DatePattern"); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } catch (IOException e) { +// String msg = String.format( +// "Unable to load '%s' from classpath: %s", +// LX_SELENIUM_RESOURCE, +// e.getMessage() +// ); +// +// fail(msg); +// } finally { +// try { +// in.close(); +// } catch (IOException e) { +// // ignore +// } +// } +// } +// } + + /** + * Returns the thread local that represents the current state of the executing + * BDD Scenario. + */ + public static CucumberContext getCucumberContext() { + return cucumberThreadLocal.get(); + } + + /** + * Returns the desired Selenium HUB URL if defined otherwise null. + */ + public static URL getSeleniumHub() { + URL url = (URL)getCucumberContext().get(SELENIUM_HUB); + + if (url != null) { + return url; + } + + String seleniumHub = getPropertyValue(SELENIUM_HUB); + + if (isNullOrEmpty(seleniumHub)) { + return null; + } + + return handleURLProperty(SELENIUM_HUB, seleniumHub); + } + + /** + * Returns the desired type of web browser. + */ + public static BrowserType getBrowserType() { + loadIWMSProperties(); + return (BrowserType)getCucumberContext().get(BROWSER); + } + + private static void loadIWMSProperties() { + if (getCucumberContext().get(IWMS_URL) == null) { + InputStream in = Credentials.class.getClassLoader().getResourceAsStream(LX_SELENIUM_RESOURCE); + + assertNotNull("Resource '" + LX_SELENIUM_RESOURCE + "' not found in classpath!", in); + + try { + Properties props = new Properties(); + String username = null; + String password = null; + String firmname = null; + + props.load(in); + + for (Object key : props.keySet()) { + String name = (String)key; + + if (IWMS_URL.equals(name)) { + handleURLProperty(name, getPropertyValue(props, IWMS_URL)); + } else if (BROWSER.equals(name)) { + handleBrowserProperty(getPropertyValue(props, BROWSER)); + } else if (IWMS_USERNAME.equals(name)) { + username = getPropertyValue(props, IWMS_USERNAME); + } else if (IWMS_PASSWORD.equals(name)) { + password = getPropertyValue(props, IWMS_PASSWORD); + } else { + logger.warning(String.format("Ignoring unexpected property '%s'", name)); + } + } + + Assert.assertNotNull( + String.format("Required property '%s' not defined!", IWMS_USERNAME), + username + ); + Assert.assertNotNull( + String.format("Required property '%s' not defined!", IWMS_PASSWORD), + password + ); + + } catch (IOException e) { + String msg = String.format( + "Unable to load '%s' from classpath: %s", + LX_SELENIUM_RESOURCE, + e.getMessage() + ); + + fail(msg); + } finally { + try { + in.close(); + } catch (IOException e) { + // ignore + } + } + } + } + + /** + * Returns the IWMS base URL. + */ +// public static URL getURL() { +// loadIWMSProperties(); +// +// return (URL)getCucumberContext().get(IWMS_URL); +// } + + /** + * Returns the IWMS authentication credentials. + */ +// public static Credentials getCredentials() { +// loadIWMSProperties(); +// +// return (Credentials)getCucumberContext().get(CREDENTIALS); +// } + + private static Pattern isoREGEX; + + /** + * Returns true if the specified string matches the XML ISO date-time pattern. + * + * @param ts - sample timestamp string to classify + */ + public static boolean isISOFormatted(String ts) { + if (ts == null) { + return false; + } + + /* Lucernex ISO format: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T05:00:00.000Z'"); + + try { + sdf.parse(ts); + return true; + } catch (ParseException e) { + return false; + } + */ + + if (isoREGEX == null) { + isoREGEX = Pattern.compile( + "^([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\17[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$" + ); + } + + synchronized (isoREGEX) { + Matcher m = isoREGEX.matcher(ts); + + if (m.find()) { + return true; + } + } + + return false; + } + + // Map of Member's LANG vs DateFormat + private static final ImmutableMap LANG_TO_DATEFORMAT = + new ImmutableMap.Builder() + .put("en", new SimpleDateFormat("MM/dd/yyyy")) + .build(); + + /** + * Revert authentication to initial user. + */ + public static void revertUser() { + throw new NotImplementedException(); + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/ForceWaitForItem.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/ForceWaitForItem.java new file mode 100755 index 000000000..be8577d30 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/ForceWaitForItem.java @@ -0,0 +1,16 @@ +package com.rl.qa.utils; + +/** + * Created by RLE0097 on 4/20/2015. + */ +public class ForceWaitForItem { + public static void delay(int intMilliSeconds){ + try { + int waitTime=intMilliSeconds; + Thread.sleep(waitTime); + //SeleniumUtilities.Log.info("Wait :" + waitTime + " Milli Seconds\n"); + } catch (Exception e) { + SeleniumUtilities.Log.error("Error :"+e.getMessage()); + } + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/SeleniumUtilities.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/SeleniumUtilities.java new file mode 100755 index 000000000..afc7e0c66 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/SeleniumUtilities.java @@ -0,0 +1,2730 @@ +package com.rl.qa.utils; + +import com.rl.qa.browsers.BrowserDriver; +import junit.framework.Assert; +import junit.framework.TestCase; +import org.apache.log4j.Logger; +import org.openqa.selenium.*; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.*; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.NoSuchElementException; +import java.util.concurrent.TimeUnit; + +import static com.rl.qa.utils.CucumberContext.getCucumberContext; +import static junit.framework.Assert.fail; +import static org.openqa.selenium.support.ui.ExpectedConditions.*; + +/** + * Commonly used Framework Function libraries + * + */ +public class SeleniumUtilities { + public static int OBJWAITTIMEOUT = 10; + public static int WEBDRIVER_WAIT = 60; + public static int WEBDRIVER_WAIT_SMALL = 30; + public static int DEFAULT_TIMEOUT_IN_SECONDS = 50, DEFAULT_SLEEP_TIME_IN_SECONDS = 50, WAIT_TIME = 50; + public static Logger Log = Logger.getLogger(Logger.class.getName()); + public static Properties objProp; + + String parentBrowser = null; + private static final String DATE_FORMAT = "MM/dd/yyyy"; + private static DateFormat formatter = new SimpleDateFormat(DATE_FORMAT); + Map map = new HashMap(); + Integer count; + public static Properties GTKey = new Properties(); + + private int waitTime = 4; + private WebDriver driver; + + + public enum Locators { + xpath, id, name, classname, paritallinktext, linktext, tagname, cssselector + } + + //WebElement el = seleniumUtil.getWebElementObject("div[id^=Covenant_CodeCovenantGroupID]", "cssSelector"); + + + public void editableField(String locator, String element, String value, int timeout) throws Exception { + //WebElement el = seleniumUtil.getWebElementObject("div[id^=Covenant_CodeCovenantGroupID]", "cssSelector"); + BaseView.pushShortTimeout(); + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + Actions action = new Actions(driver); + action.click(ele).sendKeys(value).perform(); + Log.info("Typing text '" + value + "' into text field ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + + public void editableClick(String locator, String element, int timeout) throws Exception { + //WebElement el = seleniumUtil.getWebElementObject("div[id^=Covenant_CodeCovenantGroupID]", "cssSelector"); + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { +// Actions action = new Actions(driver); +// action.click(ele).perform(); + + Actions builder = new Actions(driver); + + builder.moveToElement(ele); + builder.click(); + builder.build().perform(); + + Log.info("Clicking on field ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + + public static WebElement findElementWithTimeout(final By by, final long timeOut) throws InterruptedException { + Wait wait = new FluentWait(BrowserDriver.getCurrentDriver()) + .withTimeout(timeOut, TimeUnit.SECONDS) + .pollingEvery(500l, TimeUnit.MILLISECONDS) + .ignoring(NoSuchElementException.class) + .ignoring(StaleElementReferenceException.class); + + try { + return wait.until(presenceOfElementLocated(by)); + } catch (TimeoutException te) { + throw new InterruptedException(te.getMessage()); + } + } + + public void dragAndDropElement(String fromElementLocator, String fromElement, String targetElementLocator, String targetElement) throws Exception { + try { + WebElement fromEle = getWebElementObject(fromElementLocator, fromElement); + WebElement targetEle = getWebElementObject(targetElementLocator, targetElement); + Actions builder = new Actions(driver); + builder.moveToElement(fromEle).build().perform(); + builder.dragAndDrop(fromEle, targetEle).build().perform(); + /* Action dragAndDrop = builder.clickAndHold(fromEle) + .moveToElement(targetEle) + .release(targetEle) + .build(); + dragAndDrop.perform();*/ + + Log.info("Drag and drop of " + fromElement + " field is successful"); + } catch (Exception ex) { + Log.error("Error Message :" + ex.getMessage()); + } + } + + + public void dragAndDropElementXYOffSet(String fromElementLocator, String fromElement, int xOffset, int yOffset) throws Exception { + try { + WebElement fromEle = getWebElementObject(fromElementLocator, fromElement); + Actions builder = new Actions(driver); + builder.moveToElement(fromEle).perform(); + builder.dragAndDropBy(fromEle, xOffset, yOffset).build().perform(); + + Log.info("Drag and drop of " + fromElement + " field is successful"); + } catch (Exception ex) { + Log.error("Error Message :" + ex.getMessage()); + } + } + + public void rightClickSelectMenuOption(String locator, String element, String menuOptionLink) throws Exception { + try { + WebElement ele = getWebElementObject(locator, element); + Actions oAction = new Actions(driver); + oAction.moveToElement(ele); + for (int i = 0; i < 10; i++) { + /* this will perform right click */ + oAction.contextClick(ele).build().perform(); + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 5); + wait.until(visibilityOfElementLocated(By.cssSelector("div#folderMenu-body"))); + + break; + } catch (Exception e) { + } + } + driver.findElement(By.linkText(menuOptionLink)).click(); + /*WebElement elementOpen = driver.findElement(By.linkText(menuOptionLink)); *//*This will select menu after right click *//* + elementOpen.click();*/ + Log.info("Performed right click on menu option to select : " + menuOptionLink + " '" + locator + "=" + element + "'"); + } catch (Exception ex) { + Exception error = new Exception(element); + Log.error("Does not performed right click on menu option to select : " + menuOptionLink + " '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public void rightClickSelectMenuOption(String locator, String element, String menuLocator, String menuElement) throws Exception { + try { + WebElement ele = getWebElementObject(locator, element); + Actions oAction = new Actions(driver); + oAction.moveToElement(ele); + for (int i = 0; i < 10; i++) { + /* this will perform right click */ + oAction.contextClick(ele).build().perform(); + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 5); + wait.until(visibilityOfElementLocated(By.id("mainMenu-innerCt"))); + + break; + } catch (Exception e) { + } + } + click(menuLocator, menuElement, SeleniumUtilities.OBJWAITTIMEOUT); + + Log.info("Performed right click on menu option to select : " + locator + "=" + element + "'"); + } catch (Exception ex) { + Exception error = new Exception(element); + Log.error("Does not performed right click on menu option to select : " + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public void rightClickSelectMenuOption(WebElement ele, String menuOptionLink) throws Exception { + try { + Actions oAction = new Actions(driver); + oAction.moveToElement(ele); + oAction.contextClick(ele).build().perform(); + driver.findElement(By.linkText(menuOptionLink)).click(); + Log.info("Performed right click on menu option to select : " + menuOptionLink + " '" + ele.getText()); + } catch (Exception ex) { + Exception error = new Exception(ele.getText()); + Log.error("Does not performed right click on menu option to select : " + menuOptionLink + " '" + ele.getText()); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public void rightClickSelectMenuOption(WebElement ele, String strMovemenuOptionLink, String menuOptionLink) throws Exception { + int count = 0; + do { + count++; + try { + Actions oAction = new Actions(driver); + oAction.moveToElement(ele); + oAction.contextClick(ele).build().perform(); + + WebElement mvEle = driver.findElement(By.linkText(strMovemenuOptionLink)); + Actions mvAction = new Actions(driver); + mvAction.moveToElement(mvEle); + mvAction.click(mvEle).build().perform(); + + WebElement menuOpEle = driver.findElement(By.linkText(menuOptionLink)); + Actions menuOpAction = new Actions(driver); + menuOpAction.moveToElement(menuOpEle).build().perform(); + + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 5); + wait.until(presenceOfElementLocated(By.xpath("//span[text()='" + menuOptionLink + "'][contains(@class,'x-menu-item-text')]"))); + driver.findElement(By.xpath("//span[text()='" + menuOptionLink + "'][contains(@class,'x-menu-item-text')]")).click(); + mvAction.doubleClick(driver.findElement(By.xpath("//span[text()='" + menuOptionLink + "'][contains(@class,'x-menu-item-text')]"))); + BaseView.pushShortTimeout(); + if (!(BrowserDriver.getCurrentDriver().findElements(By.xpath("//span[text()='" + menuOptionLink + "'][contains(@class,'x-menu-item-text')]")).size() > 0)) { + break; + } + Log.info("Performed right click on menu option to select : " + menuOptionLink + " '" + ele.getText()); + } catch (Exception ex) { + + if (count == 9) { + Exception error = new Exception(ele.getText()); + Log.error("Does not performed right click on menu option to select : " + menuOptionLink + " '" + ele.getText()); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + BaseView.popDefaultTimeout(); + throw error; + } + } finally { + BaseView.popDefaultTimeout(); + } + } while (count < 10); + + } + + public Boolean rightClickVerifyMenuOption(WebElement ele, String strMovemenuOptionLink, String menuOptionLink) throws Exception { + Boolean flag = false; + try { + Actions oAction = new Actions(driver); + oAction.moveToElement(ele); + oAction.contextClick(ele).build().perform(); + + WebElement mvEle = driver.findElement(By.linkText(strMovemenuOptionLink)); + Actions mvAction = new Actions(driver); + mvAction.moveToElement(mvEle); + mvAction.click(mvEle).build().perform(); + + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 5); + //wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(menuOptionLink))); + wait.until(presenceOfElementLocated(By.xpath("//span[text()='" + menuOptionLink + "'][contains(@class,'x-menu-item-text')]"))); + flag = true; + } catch (Exception ex) { + flag = false; + } + + try { + WebElement escpmvEle = driver.findElement(By.linkText(strMovemenuOptionLink)); + Actions escpmvAction = new Actions(driver); + escpmvAction.moveToElement(escpmvEle); + escpmvAction.sendKeys(Keys.ESCAPE).build().perform(); + } catch (Exception ex) { + } + Log.info("Performed right click on menu option to verify : " + menuOptionLink + " '" + ele.getText()); + return flag; + } catch (Exception ex) { + Exception error = new Exception(ele.getText()); + Log.error("Does not performed right click on menu option to verify : " + menuOptionLink + " '" + ele.getText()); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public void dblClick(String locator, String element, int OBJWAITTIMEOUT) throws Exception { + try { + WebElement ele = getWebElementObject(locator, element); + Actions oAction = new Actions(driver); + oAction.moveToElement(ele); + oAction.doubleClick(ele).build().perform(); /* this will perform dbl click */ + Log.info("Performed double click on element : " + "'" + locator + "=" + element + "'"); + } catch (Exception ex) { + Exception error = new Exception(element); + Log.error("Does not performed double click on element : " + " '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public void doubleClickElement(WebElement element) throws Exception { + try { + BrowserDriver.waitForElement(element); + Actions oAction = new Actions(driver); + oAction.moveToElement(element); + oAction.doubleClick(element).build().perform(); /* this will perform dbl click */ + Log.info("Performed double click on element : " + "'" + "=" + element + "'"); + } catch (Exception ex) { + Log.error("Does not performed double click on element : " + "='" + element + "'"); + //fail("Does not performed double click on element : "+"='"+element+"'"+"\n"+ex.getMessage()); + } + } + + public void sendEnterKeyToElement(WebElement element) throws Exception { + try { + BrowserDriver.waitForElement(element); + Actions oAction = new Actions(driver); + oAction.moveToElement(element); + oAction.sendKeys(element, Keys.ENTER).build().perform(); /* this will perform dbl click */ + Log.info("Performed enter on element : " + "'" + "=" + element + "'"); + } catch (Exception ex) { + Log.error("Does not performed double click on element : " + "='" + element + "'"); + //fail("Does not performed double click on element : "+"='"+element+"'"+"\n"+ex.getMessage()); + } + } + + + public void dblClickSendKey(String locator, String element, String txtBoxLocator, String txtBoxElement, String strValue, int OBJWAITTIMEOUT) throws Exception { + try { + WebElement ele = getWebElementObject(locator, element); + Actions oAction = new Actions(driver); + oAction.moveToElement(ele); + oAction.doubleClick(ele).build().perform(); /* this will perform dbl click */ + + WebElement txtBoxele = getWebElementObject(txtBoxLocator, txtBoxElement); + txtBoxele.clear(); + Actions txtBoxAction = new Actions(driver); + txtBoxAction.moveToElement(txtBoxele); + txtBoxAction.sendKeys("").sendKeys(strValue).sendKeys(Keys.ENTER).build().perform(); + + Log.info("Performed double click on element and entered the value in text box: " + "'" + locator + "=" + element + "'" + "'" + strValue + "'"); + } catch (Exception ex) { + Exception error = new Exception(element); + Log.error("Does not performed double click on element : " + " '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public boolean verifyDataInTableColumns(WebElement ele, String strLabelName, String strValue) throws Exception { + int col_num = 0, matchIndex = 0; + boolean flag = false; + List tableRows = ele.findElements(By.xpath("./tbody/tr")); + + for (WebElement trElement : tableRows) { + List Cols = trElement.findElements(By.tagName("td")); + for (WebElement tdElement : Cols) { + col_num++; + if (tdElement.getText().trim().contains(strLabelName)) { + matchIndex = col_num + 1; + } else if (matchIndex == col_num) { +// String colValue = tdElement.getText().trim(); +// if (colValue.contains(",")) { +// colValue = colValue.replace(",", ""); +// } +// if (colValue.contains("$")) { +// colValue = colValue.replace("$", ""); +// } +// if (colValue.contains(".")) { +// colValue = colValue.replace(".", ""); +// } +// if (colValue.contains("%")) { +// colValue = colValue.replace("%", ""); +// } +// +// if (strValue.contains(",")) { +// strValue = strValue.replace(",", ""); +// } +// if (strValue.contains("$")) { +// strValue = strValue.replace("$", ""); +// } +// if (strValue.contains(".")) { +// strValue = strValue.replace(".", ""); +// } +// if (strValue.contains("%")) { +// strValue = strValue.replace("%", ""); +// } + String colValue = replaceSpecialChar(tdElement.getText().trim()); + strValue = replaceSpecialChar(strValue.trim()); + + if (colValue.contains(strValue) || strValue.contains(colValue) || colValue.equalsIgnoreCase(strValue)) { + matchIndex = 0; + Log.info(" Expected value :" + strLabelName + " - " + strValue + "- value exist :" + tdElement.getText().trim()); + flag = true; + return flag; + } else { + Log.error(" Expected value :" + strLabelName + " - " + strValue + "- value exist :" + tdElement.getText().trim()); + flag = false; + return flag; + } + } + } + } + if (flag == false) + Log.error("Value does not exist: " + strLabelName + " : " + strValue); + return flag; + } + +// public boolean verifyRowPairValueData(WebElement ele, String strLabelName, String strValue) throws Exception { +// int col_num = 0, matchIndex = 0; +// boolean flag = false; +// List tableRows = ele.findElements(By.xpath("./tbody/tr")); +// +// for (WebElement trElement : tableRows) { +// List Cols = trElement.findElements(By.tagName("td")); +// for (WebElement tdElement : Cols) { +// col_num++; +// if (tdElement.getText().trim().contains(strLabelName)) { +// matchIndex = col_num + 1; +// } else if (matchIndex == col_num) { +// String colValue = replaceSpecial(tdElement.getText().trim()); +// strValue = replaceSpecial(strValue.trim()); +// +// if (colValue.contains(strValue) || strValue.contains(colValue) || colValue.equalsIgnoreCase(strValue)) { +// matchIndex = 0; +// Log.info(" Expected value :" + strLabelName + " - " + strValue + "- value exist :" + tdElement.getText().trim()); +// flag = true; +// return flag; +// } else { +// Log.error(" Expected value :" + strLabelName + " - " + strValue + "- value exist :" + tdElement.getText().trim()); +// flag = false; +// return flag; +// } +// } +// } +// } +// if (flag == false) +// Log.error("Value does not exist: " + strLabelName + " : " + strValue); +// return flag; +// } + + public String replaceSpecialChar(String strData) { + if (strData.contains(",")) { + strData = strData.replace(",", ""); + } + if (strData.contains("'")) { + strData = strData.replace("'", ""); + } + if (strData.contains("$")) { + strData = strData.replace("$", ""); + } + if (strData.contains(".")) { + strData = strData.replace(".", ""); + } + if (strData.contains("%")) { + strData = strData.replace("%", ""); + } + if (strData.equalsIgnoreCase("false")) { + strData = "No/off/false"; + } + if (strData.equalsIgnoreCase("true")) { + strData = "Yes/on/true"; + } + + if (strData.equals("Yes")) { + strData = "true"; + } + if (strData.equals("No")) { + strData = "false"; + } + return strData; + } + + public boolean verifyDataInTableColumn(WebElement ele, String strLabelName, String strValue) throws Exception { + boolean flag = false; + List tableRows = ele.findElements(By.xpath("./tbody/tr")); + for (WebElement trElement : tableRows) { + List Cols = trElement.findElements(By.tagName("td")); + for (WebElement tdElement : Cols) { + if (tdElement.getText().trim().contains((strLabelName + " " + strValue))) { + Log.info(" Expected value " + strLabelName + " : " + strValue + "- Value exist " + tdElement.getText().trim()); + flag = true; + return flag; + } + } + } + if (flag == false) + Log.error("Value does not exist: " + strLabelName + " : " + strValue); + return flag; + } + + + public boolean verifySplitDataInTableColumns(WebElement ele, String strLabelName, String strValue) throws Exception { + int col_num = 0, matchIndex = 0; + boolean flag = false; + List tableRows = ele.findElements(By.xpath("./tbody/tr")); + + for (WebElement trElement : tableRows) { + List Cols = trElement.findElements(By.tagName("td")); + for (WebElement tdElement : Cols) { + col_num++; + if (tdElement.getText().trim().contains(strLabelName)) { + matchIndex = col_num + 1; + } else if (matchIndex == col_num) { + if (tdElement.getText().trim().contains(strValue)) { + matchIndex = 0; + Log.info(" Expected value :" + strLabelName + " - " + strValue + "- value exist :" + tdElement.getText().trim()); + flag = true; + return flag; + } else { + Log.error(" Expected value :" + strLabelName + " - " + strValue + "- value exist :" + tdElement.getText().trim()); + flag = false; + return flag; + } + } + } + } + if (flag == false) + Log.error("Value does not exist: " + strLabelName + " : " + strValue); + return flag; + } + + public boolean verifyDataInTableRow(WebElement ele, String strLabelName, String strValue) throws Exception { + int col_num = 0, matchIndex = 0; + boolean flag = false; + + //Fetching web elemnts using the below xpath hanging inconsistently + //List tableRows = ele.findElements(By.xpath("./tbody/tr")); + List tableRows = ele.findElements(By.cssSelector("tbody>tr")); + + for (WebElement trElement : tableRows) { + /* if((replaceSpecialChar(trElement.getText()).trim().contains(strLabelName)) && replaceSpecialChar(trElement.getText()).trim().contains(strValue)){ + Log.info(" Value exist: " + strLabelName + " : " + strValue); + flag=true; + return flag; + }*/ + } + if (flag == false) + Log.error("Value does not exist: " + strLabelName + " : " + strValue); + return flag; + } + + public boolean verifyDataInNestedTables(WebElement ele, String strNestedLocator, String strNestedElement, String strTableHeaderLocator, String strTableHeaderElement, String strTableHeadertxt, String strLabelName, String strValue) throws Exception { + int col_num = 0, matchIndex = 0; + boolean flag = false; + List tables = ele.findElements(By.cssSelector(strNestedElement)); + + for (WebElement trElement1 : tables) { + WebElement tableHeaderElement = trElement1.findElement(By.cssSelector(strTableHeaderElement)); + if (strTableHeadertxt.contentEquals(tableHeaderElement.getText())) { + List tableRows = trElement1.findElements(By.xpath("./tbody/tr")); + for (WebElement trElement : tableRows) { + List Cols = trElement.findElements(By.tagName("td")); + for (WebElement tdElement : Cols) { + col_num++; + if (tdElement.getText().trim().contains(strLabelName)) + matchIndex = col_num + 1; + else if (matchIndex == col_num) { + if (tdElement.getText().contains(strValue)) { + matchIndex = 0; + Log.info("Expected value :" + strLabelName + " - " + strValue + "- Value exist " + tdElement.getText().trim()); + flag = true; + return flag; + } else { + Log.error("Expected value :" + strLabelName + " - " + strValue + "- Value exist " + tdElement.getText().trim()); + flag = false; + return flag; + } + } + } + } + } + } + if (flag == false) + Log.error("Value does not exist: " + strLabelName + " : " + strValue); + return flag; + } + + public boolean verifyDataInNestedTablesEquals(WebElement ele, String strNestedLocator, String strNestedElement, String strTableHeaderLocator, String strTableHeaderElement, String strTableHeadertxt, String strLabelName, String strValue) throws Exception { + int col_num = 0, matchIndex = 0; + boolean flag = false; + List tables = ele.findElements(By.cssSelector(strNestedElement)); + + for (WebElement trElement1 : tables) { + WebElement tableHeaderElement = trElement1.findElement(By.cssSelector(strTableHeaderElement)); + if (strTableHeadertxt.contentEquals(tableHeaderElement.getText())) { + List tableRows = trElement1.findElements(By.xpath("./tbody/tr")); + for (WebElement trElement : tableRows) { + List Cols = trElement.findElements(By.tagName("td")); + for (WebElement tdElement : Cols) { + col_num++; + if (tdElement.getText().trim().contentEquals(strLabelName)) + matchIndex = col_num + 1; + else if (matchIndex == col_num) { + if (tdElement.getText().contains(strValue)) { + matchIndex = 0; + Log.info("Expected value :" + strLabelName + " - " + strValue + "- Value exist " + tdElement.getText().trim()); + flag = true; + return flag; + } else { + Log.error("Expected value :" + strLabelName + " - " + strValue + "- Value exist " + tdElement.getText().trim()); + flag = false; + return flag; + } + } + } + } + } + } + if (flag == false) + Log.error("Value does not exist: " + strLabelName + " : " + strValue); + return flag; + } + + public WebElement waitForElement(WebElement elementToWaitFor, Integer waitTimeInSeconds) { + WebElement ele; + if (waitTimeInSeconds == null) { + waitTimeInSeconds = OBJWAITTIMEOUT; + } + + Wait wait = new FluentWait(this.driver) + .withTimeout(waitTimeInSeconds, TimeUnit.SECONDS) + .pollingEvery(500l, TimeUnit.MILLISECONDS) + .ignoring(NoSuchElementException.class) + .ignoring(StaleElementReferenceException.class); + + ele = wait.until(elementToBeClickable((By) elementToWaitFor)); + + if (ele.isDisplayed()) { + ele.getAttribute("value"); + Log.info("Element exist '" + ele.getText()); + } else { + Log.error("Element does not exist '" + ele.getText()); + } + return ele; + } + + public SeleniumUtilities(WebDriver driver) { + this(driver, SeleniumUtilities.DEFAULT_TIMEOUT_IN_SECONDS); + } + + public SeleniumUtilities(WebDriver driver, int elementWaitTime) { + this.driver = driver; + this.waitTime = elementWaitTime; + } + + /** + * Use when element is on the page or will be on the page. Can be used element is not on the page before the ajax call and will be on the page after the ajax call + * + * @param elementId + * @param value + */ + protected void waitUntilElementGetsValue(final String elementId, final String value) { + new FluentWait(driver).withTimeout(DEFAULT_TIMEOUT_IN_SECONDS, TimeUnit.SECONDS).pollingEvery(DEFAULT_SLEEP_TIME_IN_SECONDS, TimeUnit.SECONDS).ignoring(NoSuchElementException.class).until(new ExpectedCondition() { + public Boolean apply(WebDriver wd) { + WebElement element = wd.findElement(By.id(elementId)); + return element.getText().equals(value); + } + } + ); + } + + public void waitUntilElementExists(final By by) { + new FluentWait(driver).withTimeout(DEFAULT_TIMEOUT_IN_SECONDS, TimeUnit.SECONDS).pollingEvery(DEFAULT_SLEEP_TIME_IN_SECONDS, TimeUnit.SECONDS).ignoring(NoSuchElementException.class).until(new ExpectedCondition() { + public Boolean apply(WebDriver wd) { + wd.findElement(by); + return true; + } + } + ); + } + + + public String buildTextXML(String strValue) { + return "//div[./text()='" + strValue + "'];xpath"; + } + + public void elementShouldVisible(String locator, String element, int maxTry, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isEnabled()) { + Log.info("Element visible '" + locator + "=" + element + "'"); + } else { + for (int i = 0; i < maxTry; i++) { + WebElement tryAgainele = getWebElementObject(locator, element); + if (tryAgainele.isEnabled()) { + Log.info("Element visible '" + locator + "=" + element + "'"); + break; + } else if (maxTry > i) { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + Exception error = new Exception(); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + + } + + public boolean elementShouldContain(String locator, String element, String strIntputData) throws Exception { + String strExtractedElementData = getElementText(locator, element, 1); + if (strExtractedElementData.contains(strIntputData)) { + Log.info("Verifying element'" + locator + "=" + element + "' contains text '" + strIntputData + "'"); + return true; + } else { + Log.error("Verifying element'" + locator + "=" + element + "' does not contains text '" + strIntputData + "'"); + return false; + } + } + + public boolean elementShouldNotContain(String locator, String element, String strIntputData) throws Exception { + String strExtractedElementData = getElementText(locator, element, 1); + if (!strExtractedElementData.contains(strIntputData)) { + Log.info("Verifying element'" + locator + "=" + element + "' contains text '" + strIntputData + "'"); + return true; + } else { + Log.error("Verifying element'" + locator + "=" + element + "' does not contains text '" + strIntputData + "'"); + return false; + } + } + + public void verifyText(String strExtractedData, String strIntputData) throws Exception { + if (strExtractedData.contains(strIntputData)) + Log.info("Verified data '" + strIntputData + "'"); + else + Log.error("Verified data does not exist :" + strIntputData); + } + + /** + * Adds specified number of days to the today's date + * + * @param Days Number of days to be added to the current date + * @return newdate New date returned after adding specified number of days to current date + */ + public String addDaystoCurrentDate(int Days) { + SimpleDateFormat dateformat = new SimpleDateFormat("MM/dd/yyyy"); + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.DATE, Days); //Adding 1 day to current date + String newdate = dateformat.format(cal.getTime()); + Log.info("New date '" + newdate + "'"); + System.out.println(newdate); + return (newdate); + } + + + /** + * Adds specified duration to the start date and skip week ends + * + * @param Days Number of days to be added to the current date + * @return newdate New date returned after adding specified number of days to current date + */ + public String addDaystoCurrentDateSkipWeekEndsCount(int Days) { + SimpleDateFormat dateformat = new SimpleDateFormat("MM/dd/yyyy"); + Calendar cal = Calendar.getInstance(); + int daysCount = 1; + do { + cal.add(Calendar.DATE, 1); + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY + || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) { + } else { + daysCount++; + } + if (daysCount == 30 && cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { + cal.add(Calendar.DATE, 2); + } + + if (daysCount == 30 && cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) { + cal.add(Calendar.DATE, 1); + } + + } while (daysCount < Days); + + String newdate = dateformat.format(cal.getTime()); + Log.info("New date '" + newdate + "'"); + System.out.println(newdate); + return (newdate); + } + + public String dateFormat(String strDateFormat, String strDate) throws ParseException { + SimpleDateFormat DEFAULTDATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy"); + Date mDefaultDate = DEFAULTDATE_FORMAT.parse(strDate); + SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(strDateFormat); + String newDate = DATE_FORMAT.format(mDefaultDate); + System.out.println("Today in dd-MM-yyyy format : " + strDateFormat); + return newDate; + } + + public String getDateFormat(String strDate) throws ParseException { + String newdate, strDateFormat = getCucumberContext().SESSION_DATE_FORMAT; + ; + switch (strDateFormat) { + case "dd/MM/yyyy": + newdate = dateFormat(strDateFormat, strDate); + break; + case "dd-MM-yyyy": + newdate = dateFormat(strDateFormat, strDate); + break; + case "dd.MM.yyyy": + newdate = dateFormat(strDateFormat, strDate); + break; + case "dd.MM.yyyy.": + newdate = dateFormat(strDateFormat, strDate); + break; + case "MM/dd/yyyy": + newdate = dateFormat(strDateFormat, strDate); + break; + case "MM-dd-yyyy": + newdate = dateFormat(strDateFormat, strDate); + break; + case "MM.dd.yyyy": + newdate = dateFormat(strDateFormat, strDate); + break; + case "MM.dd.yyyy.": + newdate = dateFormat(strDateFormat, strDate); + break; + case "yyyy-MM-dd": + newdate = dateFormat(strDateFormat, strDate); + break; + case "yyyy.MM.dd": + newdate = dateFormat(strDateFormat, strDate); + break; + case "yyyy.MM.dd.": + newdate = dateFormat(strDateFormat, strDate); + break; + + case "yyyy/MM/dd": + newdate = dateFormat(strDateFormat, strDate); + break; + case "yyyy.dd.MM": + newdate = dateFormat(strDateFormat, strDate); + break; + case "yyyy. MM. dd": + newdate = dateFormat(strDateFormat, strDate); + break; + case "MMMM d, yyyy": + newdate = dateFormat(strDateFormat, strDate); + break; + case "MMMM, yyyy": + newdate = dateFormat(strDateFormat, strDate); + break; + default: + newdate = dateFormat("MM/dd/yyyy", strDate); + break; + } + return (newdate); + } + + /** + * Clear the editable UI element + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param timeout customizable wait time for object to load + * @throws Exception + */ + public String getElementText(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + + if (ele.isDisplayed()) { + Log.info("Element text '" + ele.getText() + "' ''" + locator + "=" + element + "'"); + return ele.getText(); + } else { + Log.error("Element text does not exist '" + ele.getText() + "' ''" + locator + "=" + element + "'"); + return ""; + } + } + + /** + * Clear the editable UI element + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param timeout customizable wait time for object to load + * @throws Exception + */ + public void clear(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele.clear(); + Log.info("Cleared text ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public void clear(WebElement ele, int timeout) throws Exception { + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele.clear(); + Log.info("Cleared text ''" + ele); + } else { + Exception error = new Exception(); + Log.error("Current page does not contain element ''" + ele); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public void Enter(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getClickableWebElementObject(locator, element); + ele.sendKeys(Keys.RETURN); + Log.info("Clicking element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + + public void checkbox(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + if (!ele.isSelected()) + ele.click(); + Log.info("Selected checkbox ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + /** + * Clicks the UI element + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param timeout customizable wait time for object to load + * @return none + */ + public void click(String locator, String element, int timeout) throws Exception { +// WebElement ele = getWebElementObject(locator, element); + WebElement ele = getClickableWebElementObject(locator, element); + waitForObjectToLoad(ele); + //Wait(timeout); + if (ele.isDisplayed()) { +// ele = getClickableWebElementObject(locator, element); +// ele.click(); + Actions builder = new Actions(driver); +// builder.moveToElement(ele).build().perform(); +// getClickableWebElementObject(locator, element).click(); + builder.moveToElement(ele); + builder.click(getClickableWebElementObject(locator, element)); + builder.build().perform(); + + Log.info("Clicking element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void click(WebElement ele, int timeout) throws Exception { + waitForObjectToLoad(ele); + if (ele.isDisplayed()) { + Log.info("Clicking element ''" + ele.getText()); + Actions builder = new Actions(driver); + builder.moveToElement(ele); + builder.click(); + builder.build().perform(); + } else { + Exception error = new Exception(ele.getText()); + Log.error("Current page does not contain element '" + ele.getText()); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void mouseOver(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + if (ele.isDisplayed()) { + Actions builder = new Actions(driver); + builder.moveToElement(ele); + builder.build().perform(); + Log.info("mouse over to element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public static void waitForTextToAppear(WebDriver newDriver, String textToAppear, WebElement element) { + WebDriverWait wait = new WebDriverWait(newDriver, 30); + wait.until(textToBePresentInElement(element, textToAppear)); + } + + public void moveToElement(WebElement ele, int timeout) throws Exception { + Actions builder = new Actions(driver); + builder.moveToElement(ele); + builder.build().perform(); + Log.info("move to element ''" + ele.getText()); + } + + public void selectHitEnterKey(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getClickableWebElementObject(locator, element); + Actions action = new Actions(driver); + try { + action.moveToElement(ele).click().sendKeys(Keys.ENTER).build().perform(); + } catch (Exception e) { +// AllContractPagesView.focusWebElement(ele); + try { + ele.click(); + Log.info("Clicking element after last try of finding element"); + } catch (Exception last) { + Log.info("Unable to click element after last try of finding element " + last.getMessage()); + } + } + Log.info("Double clicking element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void hitEnterKey(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getClickableWebElementObject(locator, element); + Actions action = new Actions(driver); + action.moveToElement(ele).sendKeys(Keys.ENTER).build().perform(); + Log.info("Hit enter key on element''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void escape(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getClickableWebElementObject(locator, element); + Actions action = new Actions(driver); + action.moveToElement(ele).sendKeys(Keys.ESCAPE).build().perform(); + Log.info("escape element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void tab(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getClickableWebElementObject(locator, element); + Actions action = new Actions(driver); + action.moveToElement(ele).sendKeys(Keys.TAB).build().perform(); + Log.info("tab element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + /** + * Clicks the UI element + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param timeout customizable wait time for object to load + * @return none + */ + public void enter(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getClickableWebElementObject(locator, element); + ele.sendKeys(Keys.ENTER); + Log.info("Clicking element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + /** + * types data into the editable UI element + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param value test data to be populated + * @param timeout customizable wait time for object to load + */ + public void type(String locator, String element, String value, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele.sendKeys(value); + Log.info("Typing text '" + value + "' into text field ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void type(WebElement ele, String value, int timeout) throws Exception { + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele.sendKeys(value); + Log.info("Typing text '" + value + "' into text field ''" + ele.getText()); + } else { + Exception error = new Exception(ele.getText()); + Log.error("Current page does not contain element ''" + ele.getText()); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void typeHitTab(String locator, String element, String value, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + Actions action = new Actions(driver); + action.doubleClick(ele).sendKeys(Keys.chord(Keys.CONTROL, "a"), value).perform(); + action.moveToElement(ele).click(ele).sendKeys(Keys.TAB).build().perform(); + Log.info("Typing text '" + value + "' into text field ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void typeHitEnter(String locator, String element, String value, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + Actions action = new Actions(driver); + action.moveToElement(ele).click(ele).sendKeys(value).sendKeys(Keys.ENTER).build().perform(); + Log.info("Typing text '" + value + "' into text field ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public static List getDropDownOptions(WebElement webElement) { + Select select = new Select(webElement); + return select.getOptions(); + } + + public String getFirstSelectedOption(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getWebElementObject(locator, element); + Select list = new Select(ele); + Log.info("Selected '" + list.getFirstSelectedOption().getText() + "' from dropdown ''" + locator + "=" + element + "'"); + return list.getFirstSelectedOption().getText(); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void getDropDownOption(WebElement ele, String value) throws Exception { + waitForObjectToLoad(ele); + if (ele.isDisplayed()) { + Select list = new Select(ele); + list.selectByVisibleText(value); + Log.info("Selected '" + value + "' from dropdown"); + } else { + Exception error = new Exception(value); + Log.error("Current page does not contain element"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public void selectRepeatedly(String locator, String element, String value) { + try { + WebElement ele = getWebElementObject(locator, element); + ele = getWebElementObject(locator, element); + Select list = new Select(ele); + int count = 0; +// AllContractPagesView.focusWebElement(ele); + while (!list.getFirstSelectedOption().getText().trim().equals(value.trim()) && count < 10) { + list.selectByVisibleText(value); +// AllContractPagesView.focusWebElement(ele); + count++; + if (count == 10) { + break; + } + } + } catch (Exception e) { + } + } + + /** + * Selects the specified Web Radio button + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param value test data to be populated + * @timeout customizable wait time for object to load + */ + public void select(String locator, String element, String value, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getWebElementObject(locator, element); + Select list = new Select(ele); + list.selectByVisibleText(value); + selectRepeatedly(locator, element, value); + Log.info("Selected '" + value + "' from dropdown ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void select(WebElement ele, String value, int timeout) throws Exception { + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + Select list = new Select(ele); + list.selectByVisibleText(value); + Log.info("Selected '" + value + "' from dropdown ''" + ele.getText()); + } else { + Exception error = new Exception(ele.getText()); + Log.error("Current page does not contain element ''" + ele.getText()); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + /** + * Selects the drop down box by value + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param value test data to be populated + * @timeout customizable wait time for object to load + */ + public void selectByValue(String locator, String element, String value, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + Select list = new Select(ele); + list.selectByValue(value); + Log.info("Selected '" + value + "' from dropdown ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + /** + * Types the date in date web control + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param value date value to be populated + * @param timeout customizable wait time for object to load + */ + public void dateType(String locator, String element, String value, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele.clear(); + if (value.contains("/")) { + ele.sendKeys(value); + } else { + String curDate = currentDate(Integer.parseInt(value)); + ele.sendKeys(curDate); + } + driver.findElement(By.className("ui-datepicker-close")).click(); // Click on the Close line in datepicker window. + Wait(1); + Log.info("Clicking element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void clickOnCellValue(String locator, String element, String cellValue) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + if (ele.isDisplayed()) { + List tblRow = ele.findElements(By.tagName("tr")); + for (int i = 0; i <= tblRow.size(); i++) { + System.out.println(tblRow.get(i).toString()); + Log.info("Clicking element ''" + locator + "=" + element + "'"); + } + + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + /** + * Determines the type of the UI web element based on the UI obeject description + * + * @param propValue UI object name description + * @param propName type of the property descrtiption like "id","name", "xpath", tagname" etc + * @return the identified web element + * @throws Exception + */ + public WebElement getWebElementObject(String locator, String element) throws Exception { + By byElement; + try { + byElement = getElementBy(locator, element); + Wait wait = new FluentWait(this.driver) + .withTimeout(this.waitTime, TimeUnit.SECONDS) + .pollingEvery(500l, TimeUnit.MILLISECONDS) + .ignoring(NoSuchElementException.class) + .ignoring(StaleElementReferenceException.class); + + WebElement webelement = wait.until(presenceOfElementLocated(byElement)); + waitForObjectToLoad(webelement); + return webelement; // return webelement object + } catch (Exception ex) { + String Str = new String(ex.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw ex; + } + } + + public List getWebElementObjects(String locatorType, String locator, int counter, int timeOut) throws Exception { + List eles = null; + for (int i = 0; i < counter; i++) { + try { + BaseView.pushShortTimeout(1); + eles = BrowserDriver.getCurrentDriver().findElements(getElementBy(locatorType, locator)); + for (WebElement ele : eles) { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + ele = wait.until(visibilityOf(ele)); + if (ele.isDisplayed()) return eles; + } + } catch (StaleElementReferenceException se) { + + } catch (Exception ne) { + Log.error("Webelements does not exist : " + locatorType + " : " + locator + "counter :" + counter); + } finally { + BaseView.popDefaultTimeout(); + } + } + return eles; + } + + public WebElement getClickableWebElementObject(String locator, String element) throws Exception { + By byElement; + try { + byElement = getElementBy(locator, element); + Wait wait = new FluentWait(this.driver) + .withTimeout(this.waitTime, TimeUnit.SECONDS) + .pollingEvery(500l, TimeUnit.MILLISECONDS) + .ignoring(NoSuchElementException.class) + .ignoring(StaleElementReferenceException.class); + + WebElement webelement = wait.until(elementToBeClickable(byElement)); + wait.until(visibilityOf(webelement)); + waitForObjectToLoad(webelement); + return webelement; // return webelement object + } catch (Exception ex) { + String Str = new String(ex.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw ex; + } + } + + public WebElement getClickableWebElementObject(WebElement byElement) throws Exception { + try { + Wait wait = new FluentWait(this.driver) + .withTimeout(this.waitTime, TimeUnit.SECONDS) + .pollingEvery(500l, TimeUnit.MILLISECONDS) + .ignoring(NoSuchElementException.class) + .ignoring(StaleElementReferenceException.class); + + WebElement webelement = wait.until(elementToBeClickable(byElement)); + wait.until(visibilityOf(webelement)); + waitForObjectToLoad(webelement); + return webelement; // return webelement object + } catch (Exception ex) { + String Str = new String(ex.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw ex; + } + } + + public void Wait(int timeout) { + long t1, t2; + t1 = System.currentTimeMillis(); + + do { + t2 = System.currentTimeMillis(); + } + while ((t2 - t1) < (timeout * 1000)); + + } + + /** + * Waits for the UI object to completed load on webpage + * + * @param ele UI element for which wait time is required to load + */ + public void waitForObjectToLoad(WebElement ele) { + boolean isExist = false; + int cntr = 0; + while (!isExist) { + if (ele.isDisplayed()) { + isExist = true; + } else { + Wait(1); + cntr++; + if (cntr >= 240) { // Maximum wait time is for 120 seconds i.e. 2 minutes + //fail + isExist = true; + } + } + } + } + + public static String currentDate(int num) { + Calendar c1 = Calendar.getInstance(); + c1.add(Calendar.DATE, num); + return formatter.format(c1.getTime()); + } + + /** + * checks whether the element is present on webpage + * + * @param by String UI object reference + * @return returns true or false based on whether UI object present on the webpage + */ + public boolean isElementPresent(String by) { + try { + driver.findElement(By.xpath(by)); + Log.info("Element " + by + " exist."); + return true; + } catch (NoSuchElementException e) { + Log.info("Element does not " + by + " exist."); + return false; + } + } + + /** + * checks whether the element is present on webpage + * + * @param by UI object reference + * @return returns true or false based on whether UI object present on the webpage + */ + public boolean isElementPresent(By by) { + try { + driver.findElement(by); + return true; + } catch (NoSuchElementException e) { + return false; + } + } + + + /** + * Handles intestistial page + */ + public void handle() { + try { + + String windowHandle = driver.getWindowHandle(); + driver.switchTo().window(windowHandle); + + } catch (Exception e) { + System.out.println(e); + } + + } + + public void switchToFrame(int index) { + try { + driver.switchTo().frame(index); + } catch (Exception e) { + Log.error("Error :" + e.getMessage()); + } + } + + public void switchTodefaultContent() { + try { + driver.switchTo().defaultContent(); + } catch (Exception e) { + Log.error("Error :" + e.getMessage()); + } + } + + /** + * Clicks on the link present on a webtable for a specifed row and column + * + * @param ele UI element for which wait time is required to load + * @throws Exception + */ + public void randomClick(String locator, String element, int ClickRow, int ClickCol) throws Exception { + int row_num = 1, col_num, ClickedFlag = 0; + WebElement TableElement = getWebElementObject(locator, element); + List Rows = TableElement.findElements(By.xpath("id('" + element + "')/tbody/tr")); + for (WebElement trElement : Rows) { + if (row_num > ClickRow) { + List Cols = trElement.findElements(By.xpath("td")); + col_num = 1; + for (WebElement tdElement : Cols) { + if (col_num > ClickCol) { + if (tdElement.getText() != "") + if (tdElement.getText() != "N/A") + if (tdElement.getText().length() < 12) { + driver.findElement(By.linkText(tdElement.getText())).click(); + ClickedFlag = 1; + break; + } + System.out.println("row # " + row_num + ", col # " + col_num + "text=" + tdElement.getText()); + } + col_num++; + } + if (ClickedFlag == 1) + break; + } + row_num++; + } + } + + public int getTableRowCount(String locator, String element) throws Exception { + WebElement TableElement = getWebElementObject(locator, element); + List Rows = TableElement.findElements(By.xpath(element)); + Log.info("Total Rows '" + Rows.size() + "' ''" + locator + "=" + element + "'"); + return Rows.size(); + } + + public String getTableColumnValue(String locator, String element, int intRow, int intCol) throws Exception { + int row_num = 1, col_num, boolExitFlag = 0; + String strColText = ""; + WebElement TableElement = getWebElementObject(locator, element); + List Rows = TableElement.findElements(By.xpath("" + element + "/tbody/tr")); + for (WebElement trElement : Rows) { + if (row_num == intRow) { + List Cols = trElement.findElements(By.xpath("td")); + col_num = 1; + for (WebElement tdElement : Cols) { + if (col_num == intCol) { + strColText = tdElement.getText(); + Log.info("Extracted element value '" + tdElement.getText() + "' ''" + locator + "=" + element + "'"); + boolExitFlag = 1; + break; + } + } + if (boolExitFlag == 1) + break; + } + } + row_num++; + return strColText; + } + + public String getLastIndexTextValue(String locator, String element, int timeout) throws Exception { + //String[] propertyNameValue= propertyNameAndValue.split(";"); + List eles = driver.findElements(getElementBy(locator, element)); + if (eles.get(eles.size() - 1).isDisplayed()) { + Log.info("Extracted element value '" + eles.get(eles.size() - 1).getText() + "' ''" + locator + "=" + element + "'"); + return eles.get(eles.size() - 1).getText().trim(); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + public boolean verifyTextValue(String locator, String element, String strMsg, int timeout) { + boolean flag = false; + try { + List eles = driver.findElements(getElementBy(locator, element)); + + for (int i = 0; i < eles.size(); i++) { +// AllContractPagesView.focusWebElement(eles.get(i)); + if (eles.get(i).getText().trim().contains(strMsg.trim())) { + flag = true; + Log.info("Extracted element value '" + eles.get(i).getText() + "' ''" + locator + "=" + element + "'"); + return flag; + } + } + if (flag == false) { + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + } + } catch (Exception ex) { + return false; + } + return flag; + } + + public Boolean isElementExist(String locator, String element) { + Boolean flag = false; + try { + if (getWebElementObject(locator, element).isDisplayed()) + flag = true; + } catch (Exception ex) { + flag = false; + } + return flag; + } + + /** + * Captures the text value of the web element + * + * @param propertyNameAndValue UI Property name and value delimited by ";" + * @param timeout customizable wait time for object to load + * @return ele returns the captured text + */ + public String getTextValue(String locator, String element, int timeout) throws Exception { + //String[] propertyNameValue= propertyNameAndValue.split(";"); + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getWebElementObject(locator, element); + Log.info("Extracted element value '" + ele.getText() + "' ''" + locator + "=" + element + "'"); + return ele.getText().trim(); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public String getTextValue(WebElement ele, int timeout) throws Exception { + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + Log.info("Extracted element value '" + ele.getText() + "' ''" + ele); + return ele.getText().trim(); + } else { + Exception error = new Exception(); + Log.error("Current page does not contain element ''" + ele); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + /** + * Checks whether element is enabled in UI. + * + * @param element The UI element to be validated + * @return true or false depending on whether UI element is enabled. + */ + + public static boolean assertNull(WebElement element) { + try { + // call any method on the element + element.isEnabled(); + Log.info("Element enabled"); + } catch (Exception ex) { + Log.error("Current page does not contain element"); + String Str = new String(ex.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + return true; + } + return false; + } + + /** + * Checks whether element is not enabled in UI. + * + * @param element The UI element to be validated + * @return true or false depending on whether UI element is enabled. + */ + public static boolean assertNotNull(WebElement element) { + try { + // call any method on the element + if (element.isEnabled()) + Log.info("Element enabled"); + } catch (Exception ex) { + Log.error("Current page does not contain element"); + String Str = new String(ex.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + return false; + } + return true; + } + + /* + * findWebelement method looks for the presence of the element and clicks on the same. + * + * @param xpath String: xpath is the element + */ + public void findWebElement(String xpath) { + WebElement Elements = null; + + try { + By ElementLocator = By.xpath(xpath); + Elements = driver.findElement(ElementLocator); + Elements.click(); + Log.info("Clicking element"); + } catch (Exception Ex) { + Log.error("Current page does not contain element"); + String Str = new String(Ex.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + System.out.println("FindWebElement Functiion : " + Ex.getMessage()); + } + } + + /** + * Returns the Attribute value for a given Webelement object + * + * @param propertyNameAndValue: Webelement object + * @param attribute: Attribute name for which the value to be returned + * *@param timeout: default timeout + * @return Attribute value + */ + public String getAttributeValue(String locator, String element, String attribute, int timeout) throws Exception { + //String[] propertyNameValue= propertyNameAndValue.split(";"); + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + Log.info("Attribute of the element '" + ele.getAttribute(attribute) + "' ''" + locator + "=" + element + "'"); + return ele.getAttribute(attribute); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } + + + /** + * This method returns the Selected item value from the dropdown. + * + * @param propertyNameAndValue: Listbox Object + * @param timeout: default timeout + * @return String : Item value selected in the dropdown + */ + public String getSelectedValue(String locator, String element, int timeout) throws Exception { + //String[] propertyNameValue= propertyNameAndValue.split(";"); + WebElement ele = getWebElementObject(locator, element); + Wait(timeout); + if (ele.isDisplayed()) { + Select list = new Select(ele); + WebElement val = list.getFirstSelectedOption(); + Log.info("Selected '" + val.getText() + "' ''" + locator + "=" + element + "'"); + return val.getText(); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public String getTableText(String locator, String element) throws Exception { + WebElement TableElement = getWebElementObject(locator, element); + Log.info("Table Value '" + TableElement.getText() + "' ''" + locator + "=" + element + "'"); + return TableElement.getText(); + } + + public List getTableValues(String locator, String element, int ClickRow, int ClickCol) throws Exception { + WebElement TableElement = getWebElementObject(locator, element); + List Rows = TableElement.findElements(By.xpath(element + "/tbody/tr")); + Log.info("Selected '" + TableElement.getText() + "' ''" + locator + "=" + element + "'"); + return Rows; + } + + public int getXpathCount(String xpathValue) throws Exception { + return driver.findElements(By.xpath(xpathValue)).size(); + } + + public WebDriver getWebDriver() { + return driver; + } + +// public void getChildWindow(boolean flag) throws Throwable{ +// try{ +// if(flag){ +// parentBrowser = driver.getWindowHandle(); +// Iterator i = driver.getWindowHandles().iterator(); +// while(i.hasNext()) { +// String childBrowser = i.next(); +// driver.switchTo().window(childBrowser); +// } +// }else{ +// driver.close(); +// driver.switchTo().window(parentBrowser); +// } +// } catch (Exception e) { +// } +// } + + public void getChildWindow(boolean flag) throws Throwable { + try { + parentBrowser = driver.getWindowHandle(); + if (flag) { + Iterator i = driver.getWindowHandles().iterator(); + while (i.hasNext()) { + String childBrowser = i.next(); + driver.switchTo().window(childBrowser); + } + } + driver.close(); + driver.switchTo().window(parentBrowser); + } catch (Exception e) { + } + } + + public void waitForPopUp(long count) throws Throwable { + int time = 0; + boolean flag = false; + try { + while (time < count) { + time++; + Thread.sleep(1000); + Set i = driver.getWindowHandles(); + if (i.toArray().length > 1) { + flag = true; + break; + } + } + if (time == count) { + throw new Exception("Pop up not found"); + } + } catch (Exception e) { + } + } + + public boolean handelPopWindow(long count) { + int time = 0; + boolean flag = false; + try { + while (time < count) { + time++; + Thread.sleep(1000); + Set i = driver.getWindowHandles(); + if (i.toArray().length > 1) { + flag = true; + return flag; + //break; + } + } + if (time == count) { + throw new Exception("Pop up not found"); + } + } catch (Exception e) { + } + return flag; + } + + public void verifyLabelAndValuePair(String strType, String strValue) throws Exception { + Assert.assertTrue("Expected type " + strType + " and pair " + strValue + " NOT found", getWebElementObject("xpath", "//td[contains(text(),'" + strType + "')]//following-sibling::td").getText().trim().replace(",", "").replace(".", "").contains(strValue.replace(",", "").replace(".", ""))); + Log.info("Expected type " + strType + " and pair " + strValue + " exist"); + } + + + public void focusAndClick(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getClickableWebElementObject(locator, element); +// ele.sendKeys(""); +// ele.click(); + Actions builder = new Actions(driver); + builder.moveToElement(ele); + builder.sendKeys(""); + builder.click(); + builder.build().perform(); + + Log.info("Clicking element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public void moveToElement(String locator, String element, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + ele = getClickableWebElementObject(locator, element); + Actions builder = new Actions(driver); + builder.moveToElement(ele); +// builder.sendKeys(""); + builder.build().perform(); + ele.sendKeys(""); + Log.info("Clicking element ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element '" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + + } + + public By getElementBy(String locator, String element) throws Exception { + By byElement; + try { + switch (Locators.valueOf(locator.toLowerCase())) { // determine which locator item we are interested in + case xpath: { + byElement = By.xpath(element); + break; + } + case id: { + byElement = By.id(element); + break; + } + case name: { + byElement = By.name(element); + break; + } + case classname: { + byElement = By.className(element); + break; + } + case linktext: { + byElement = By.linkText(element); + break; + } + case paritallinktext: { + byElement = By.partialLinkText(element); + break; + } + case tagname: { + byElement = By.tagName(element); + break; + } + case cssselector: { + byElement = By.cssSelector(element); + break; + } + default: { + throw new InvalidSelectorException(locator + + " is not a valid Selector."); + } + } + return byElement; + } catch (Exception ex) { + String Str = new String(ex.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw ex; + } + } + + public void clickElement(String locator, String element, int count) throws Exception { + int localCount = 0; + while (!(localCount == count)) { + + try { + //This element focus will work only for link, input etc. Therefore surrounded with try catch + try { + getWebElementObject(locator, element).sendKeys(""); + getClickableWebElementObject(locator, element).sendKeys(""); + + } catch (Exception e) { + } +// getWebElementObject(locator, element).click(); + click(locator, element, waitTime); + break; + } catch (StaleElementReferenceException e) { + localCount++; + } + } + } + + public void handleUnexpectedAlerts() throws Exception { + try { +// ForceWaitForItem.delay(10000); + WebDriverWait wait = new WebDriverWait(driver, 4); + wait.ignoring(NoAlertPresentException.class) + .until(alertIsPresent()); + Alert alert = BrowserDriver.getCurrentDriver().switchTo().alert(); + alert.accept(); + } catch (Exception e) { + } + } + + public void handleParticularAlert(String alertMessage) throws Exception { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 5); + wait.until(alertIsPresent()); + Alert alert = BrowserDriver.getCurrentDriver().switchTo().alert(); + if (alertMessage.trim().contains(alert.getText().trim())) { + alert.accept(); + } else { + System.out.println("Alert not found"); + } + } catch (Exception e) { + } + } + + public void dismissUnexpectedAlerts() throws Exception { + try { +// ForceWaitForItem.delay(5000); + WebDriverWait wait = new WebDriverWait(driver, 10); + wait.ignoring(NoAlertPresentException.class) + .until(alertIsPresent()); + + Alert alert = BrowserDriver.getCurrentDriver().switchTo().alert(); + alert.dismiss(); + } catch (Exception e) { + } + } + + public void switchToFrameHavingElement(String locatorType, String locator) { + int count = 0; + driver.switchTo().defaultContent(); + + //Wait for frame to load + WebDriverWait wait = new WebDriverWait(driver, OBJWAITTIMEOUT); + wait.until(frameToBeAvailableAndSwitchToIt(By.cssSelector("iframe"))); + + driver.switchTo().defaultContent(); + List elements = this.getWebDriver().findElements(By.cssSelector("iframe")); + Log.info("Number of frames in this page : " + elements.size()); + + for (WebElement e : elements) { + driver.switchTo().defaultContent(); + System.out.println(e.getAttribute("src")); + driver.switchTo().frame(e); + try { + this.getWebElementObject(locatorType, locator); + Log.info("Element is found in frame " + (count + 1)); + break; + } catch (Exception ec) { + count++; + } + } + if (count == elements.size()) { + Log.info("Element is not found in any of the frames"); + driver.switchTo().defaultContent(); + //throw new NoSuchElementException("Element is not found in any of the frames"); + } + } + + public boolean getFrameIndex(String locatorType, String locator) { + int count = 0; + boolean flag = false; + driver.switchTo().defaultContent(); + + //Wait for frame to load + WebDriverWait wait = new WebDriverWait(driver, OBJWAITTIMEOUT); + wait.until(frameToBeAvailableAndSwitchToIt(By.cssSelector("iframe"))); + + driver.switchTo().defaultContent(); + List elements = this.getWebDriver().findElements(By.cssSelector("iframe")); + Log.info("Number of frames in this page : " + elements.size()); + + for (WebElement e : elements) { + driver.switchTo().defaultContent(); + System.out.println(e.getAttribute("src")); + driver.switchTo().frame(e); + try { +// if(count!=0) { + BaseView.pushShortTimeout(1); + this.getWebElementObject(locatorType, locator); + Log.info("Element is found in frame " + (count + 1)); + flag = true; + break; +// } +// count++; + } catch (Exception ec) { + count++; + } finally { + BaseView.popDefaultTimeout(); + } + } +// if (count == elements.size()) { +// Log.info("Element is not found in any of the frames"); +// driver.switchTo().defaultContent(); +// //throw new NoSuchElementException("Element is not found in any of the frames"); +// } + return true; + } + + public static void selectDropdownOption(By by, String optionName) { + + WebElement optionNames = BrowserDriver.getCurrentDriver().findElement(by); + Select select = new Select(optionNames); + select.selectByVisibleText(optionName); + + } + /*public void waitForPageLoad() { + + try{ + JavascriptExecutor js = (JavascriptExecutor)driver; + final boolean response = js.executeScript("return document.readyState").equals("complete"); + WebDriverWait wait = new WebDriverWait(driver,30000,5000); + wait.until(new Predicate() { + public boolean apply(WebDriver arg0) { + return response; + } + }); + Log.info("Page is loaded completely...."); + }catch(Exception e){ + //Ignore + } + }*/ + +// private void readExcelSheet(String destFile){ +// File excelSheet = null; +// Workbook workbook = null; +// +// try { +// Workbook wb = Workbook.getWorkbook(new File(destFile)); +// System.out.println(wb.getNumberOfSheets()); +// for(int sheetNo=0; sheetNo tableRows = ele.findElements(By.xpath("./tbody/tr")); + for (WebElement trElement : tableRows) { + List Cols = trElement.findElements(By.tagName("td")); + for (WebElement tdElement : Cols) { + // System.out.println(tdElement.getText().trim()+"===="+strLabelName+":"+strValue); + if (tdElement.getText().trim().contains((strLabelName + "\n" + strValue))) { + Log.info(" Expected value " + strLabelName + " : " + strValue + "- Value exist " + tdElement.getText().trim()); + flag = true; + return flag; + } + } + } + if (flag == false) + Log.error("Value does not exist: " + strLabelName + " : " + strValue); + return flag; + } + + public WebElement getWebElementWithoutStaleness(String locator, String element) throws Exception { + By byElement; + WebElement webelement = null; + int staleElementCount = 0; + do { + try { + byElement = getElementBy(locator, element); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), WEBDRIVER_WAIT_SMALL); + wait.until(not(stalenessOf(BrowserDriver.getCurrentDriver().findElement(byElement)))); + webelement = BrowserDriver.getCurrentDriver().findElement(byElement); + break; + } catch (StaleElementReferenceException se) { + staleElementCount++; + } catch (NoSuchElementException ne) { + BaseView.takeScreenshot("ElementNotFound.png"); + fail("Element not found in the DOM " + ne.getMessage()); + } + } while (!(staleElementCount > 15)); + return webelement; + } + + public static boolean waitForNonStaleWebElement(WebElement element, int timeOut) { + boolean flag = false; + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + return wait.until(not(stalenessOf(element))); + } catch (Exception e) { + Log.info("Error: Waited for non stale element for " + timeOut + " seconds but no use..."); + return flag; + } finally { + BaseView.popDefaultTimeout(); + } + } + + public static boolean waitForNonStaleWebElement(WebElement element, int counter, int timeOut) { + boolean flag = false; + for (int i = 0; i < counter; i++) { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + boolean ele = wait.until(not(stalenessOf(element))); + if (ele) return ele; + } catch (Exception e) { + Log.info("Error: Waited for non stale element for " + timeOut + " seconds but no use..."); + } finally { + BaseView.popDefaultTimeout(); + } + } + return flag; + } + + public boolean waitForNonStaleWebElement(String locatorType, String locator, int timeOut) { + boolean flag = false; + try { + BaseView.pushShortTimeout(2); + WebElement element = getWebElementObject(locatorType, locator); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + return wait.until(not(stalenessOf(element))); +// flag = wait.until(ExpectedConditions.not(ExpectedConditions.stalenessOf(element))); +// flag = true; + } catch (Exception e) { + Log.info("Error: Waited for non stale element for \"+timeOut+\" seconds but no use..." + e.getMessage()); + } finally { + BaseView.popDefaultTimeout(); + } + return flag; + } + + public boolean waitForNonStaleWebElement(String locatorType, String locator, int counter, int timeOut) { + boolean flag = false; + for (int i = 0; i < counter; i++) { + try { + BaseView.pushShortTimeout(2); + WebElement element = getWebElementObject(locatorType, locator); + + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + flag = wait.until(not(stalenessOf(element))); + if (flag) return flag; + } catch (Exception e) { + Log.info("Error: Waited for non stale element for " + timeOut + " seconds but no use..."); + } finally { + BaseView.popDefaultTimeout(); + } + } + return flag; + } + + public boolean waitForElementContainText(WebElement element, String text) throws Exception { + boolean textPresent = false; + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), WEBDRIVER_WAIT); + textPresent = wait.until(textToBePresentInElement(element, text)); + } catch (Exception ne) { + BaseView.takeScreenshot("TextNotFoundInElement.png"); + fail("Element not found in the DOM " + ne.getMessage()); + } + return textPresent; + } + + public boolean waitForElementContainText(String locatorType, String locator, String text) throws Exception { + boolean textPresent = false; + try { + BaseView.pushShortTimeout(1); + WebElement element = getWebElementObject(locatorType, locator); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), WEBDRIVER_WAIT); + textPresent = wait.until(textToBePresentInElement(element, text)); + } catch (Exception ne) { + Log.error("Webelement does not exist : " + locatorType + " : " + locator); + } finally { + BaseView.popDefaultTimeout(); + } + return textPresent; + } + + public boolean waitForElementVisibilityOf(String locatorType, String locator, int timeOut) { + try { + BaseView.pushShortTimeout(1); + WebElement element = getWebElementObject(locatorType, locator); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + return wait.until(visibilityOf(element)).isDisplayed(); + } catch (Exception ne) { + Log.error("Webelement does not exist : " + locatorType + " : " + locator); + return false; + } finally { + BaseView.popDefaultTimeout(); + } + } + + /*public boolean waitForElementVisibilityOf(String element, int timeOut){ + try { + BaseView.pushShortTimeout(1); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + return wait.until(visibilityOf(element)).isDisplayed(); + } catch (Exception ne) { + Log.error("Webelement does not exist : " + element.getText()); + return false; + }finally{ + BaseView.popDefaultTimeout(); + } + }*/ + + public boolean waitForElementVisibilityOf(WebElement element, int counter, int timeOut) { + boolean eleVisibile = false; + for (int i = 0; i < counter; i++) { + try { + BaseView.pushShortTimeout(1); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + eleVisibile = wait.until(visibilityOf(element)).isDisplayed(); + if (eleVisibile) return eleVisibile; + } catch (Exception ne) { + Log.error("Webelement does not exist : " + element.getText()); + } finally { + BaseView.popDefaultTimeout(); + } + } + return eleVisibile; + } + + public boolean waitForElementVisibilityOf(String locatorType, String locator, int counter, int timeOut) { + boolean eleVisibile = false; + for (int i = 0; i < counter; i++) { + try { + BaseView.pushShortTimeout(1); + WebElement element = getWebElementObject(locatorType, locator); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + eleVisibile = wait.until(visibilityOf(element)).isDisplayed(); + if (eleVisibile) return eleVisibile; + } catch (Exception ne) { + Log.error("Webelement does not exist : " + locatorType + " : " + locator + "counter :" + counter); + } finally { + BaseView.popDefaultTimeout(); + } + } + return eleVisibile; + } + + public boolean waitForElementIsClickable(String locatorType, String locator, int counter, int timeOut) { + boolean eleVisibile = false; + for (int i = 0; i < counter; i++) { + try { + BaseView.pushShortTimeout(1); + WebElement element = getWebElementObject(locatorType, locator); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + eleVisibile = wait.until(elementToBeClickable(element)).isDisplayed(); + if (eleVisibile) return eleVisibile; + } catch (Exception ne) { + Log.error("Webelement does not exist : " + locatorType + " : " + locator + "counter :" + counter); + } finally { + BaseView.popDefaultTimeout(); + } + } + return eleVisibile; + } + + public boolean waitForElementIsClickable(WebElement element, int counter, int timeOut) { + boolean eleVisibile = false; + for (int i = 0; i < counter; i++) { + try { + BaseView.pushShortTimeout(1); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + eleVisibile = wait.until(elementToBeClickable(element)).isDisplayed(); + if (eleVisibile) return eleVisibile; + } catch (Exception ne) { + Log.error("Webelement does not exist : " + element.getText() + "counter :" + counter); + } finally { + BaseView.popDefaultTimeout(); + } + } + return eleVisibile; + } + + public WebElement getElement(String locatorType, String locator, int timeOut) { + WebElement element = null; + try { + BaseView.pushShortTimeout(1); + element = getWebElementObject(locatorType, locator); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + element = wait.until(visibilityOf(element)); + } catch (Exception ne) { + Log.error("Webelement does not exist : " + locatorType + " : " + locator); + } finally { + BaseView.popDefaultTimeout(); + } + return element; + } + + public WebElement getElement(String locatorType, String locator, int counter, int timeOut) { + WebElement element = null; + for (int i = 0; i < counter; i++) { + try { + BaseView.pushShortTimeout(1); + element = getClickableWebElementObject(locatorType, locator);//BrowserDriver.getCurrentDriver().findElement(getElementBy(locatorType, locator)); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + element = wait.until(visibilityOf(element)); + if (element.isDisplayed()) return element; +// wait.until(ExpectedConditions.not(ExpectedConditions.stalenessOf(element))); + } catch (StaleElementReferenceException se) { + + } catch (Exception ne) { + Log.error("Webelement does not exist : " + locatorType + " : " + locator + "counter :" + counter); + } finally { + BaseView.popDefaultTimeout(); + } + } + return element; + } + + public boolean waitForElementNotPresent(String locatorType, String locator) throws Throwable { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), WEBDRIVER_WAIT); + wait.until(invisibilityOfElementLocated(getElementBy(locatorType, locator))); + return true; + } catch (Exception e) { + return false; + } + } + + public boolean waitForElementNotPresent(String locatorType, String locator, int timeOut) throws Throwable { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + wait.until(invisibilityOfElementLocated(getElementBy(locatorType, locator))); + return true; + } catch (Exception e) { + return false; + } + } + + public boolean waitForElementPresent(String locatorType, String locator) throws Throwable { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), WEBDRIVER_WAIT); + wait.until(visibilityOfElementLocated(getElementBy(locatorType, locator))); + return true; + } catch (Exception e) { + return false; + } + } + + public boolean waitUntilElementContainsText(String locatorType, String locator, String text, int timeOut) throws Exception { + boolean textPresent = false; + try { + WebDriverWait wait = new WebDriverWait(driver, timeOut); + textPresent = wait.until(textToBePresentInElement(getElement(locatorType, locator, timeOut), text)); + if (textPresent) return textPresent; + } catch (Exception ne) { + BaseView.takeScreenshot("TextNotFoundInElement.png"); + Log.info("Error :" + ne.getMessage()); + return textPresent; + } finally { + BaseView.popDefaultTimeout(); + } + return textPresent; + } + + public boolean waitUntilElementContainsText(String locatorType, String locator, String text, int counter, int timeOut) throws Exception { + boolean textPresent = false; + for (int i = 0; i < counter; i++) { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + textPresent = wait.until(textToBePresentInElement(getElement(locatorType, locator, timeOut), text)); + if (textPresent) return textPresent; + } catch (Exception ne) { + BaseView.takeScreenshot("TextNotFoundInElement.png"); + Log.info("Error :" + ne.getMessage()); + } finally { + BaseView.popDefaultTimeout(); + } + } + return textPresent; + } + + public boolean waitUntilElementNotContainsText(String locatorType, String locator, String text, int counter, int timeOut) throws Exception { + boolean textPresent = false; + for (int i = 0; i < counter; i++) { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + textPresent = wait.until(not(textToBePresentInElement(getElement(locatorType, locator, timeOut), text))); + if (textPresent) return textPresent; + } catch (Exception ne) { + BaseView.takeScreenshot("TextNotFoundInElement.png"); + Log.info("Error :" + ne.getMessage()); + } finally { + BaseView.popDefaultTimeout(); + } + } + return textPresent; + } + + public boolean waitUntilElementNotContainsText(WebElement ele, String text, int counter, int timeOut) throws Exception { + boolean textPresent = false; + for (int i = 0; i < counter; i++) { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + textPresent = wait.until(not(textToBePresentInElement(ele, text))); + if (textPresent) return textPresent; + } catch (Exception ne) { + BaseView.takeScreenshot("TextNotFoundInElement.png"); + Log.info("Error :" + ne.getMessage()); + } finally { + BaseView.popDefaultTimeout(); + } + } + return textPresent; + } + + public static void failed(String errorMessage) { + org.junit.Assert.fail(errorMessage); + } + + public boolean waitUntilElementDisappers(String locatorType, String locator, int counter, int timeOut) throws Exception { + boolean boolEleExist = false; + for (int i = 0; i < counter; i++) { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + boolEleExist = wait.until(not(visibilityOf(getElement(locatorType, locator, timeOut)))); + if (boolEleExist) return boolEleExist; + } catch (Exception ne) { + BaseView.takeScreenshot("waitUntilElementDisappers"); + Log.info("Error :" + ne.getMessage()); + } finally { + BaseView.popDefaultTimeout(); + } + } + return boolEleExist; + } + + public boolean waitUntilElementDisappers(WebElement ele, int counter, int timeOut) throws Exception { + boolean boolEleExist = false; + for (int i = 0; i < counter; i++) { + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), timeOut); + boolEleExist = wait.until(not(visibilityOf(ele))); + if (boolEleExist) return boolEleExist; + } catch (Exception ne) { + BaseView.takeScreenshot("waitUntilElementDisappers"); + Log.info("Error :" + ne.getMessage()); + } finally { + BaseView.popDefaultTimeout(); + } + } + return boolEleExist; + } + + public boolean textContains(String strSearchText) { + boolean flag = false; + try { + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 30); + return wait.until(textToBePresentInElement(By.tagName("*"), strSearchText)); + } catch (Exception ex) { + Log.error("Text doesnot contains :" + strSearchText + ex.getMessage()); + } + Log.info("Verified : " + strSearchText); + return flag; + } + + public static void switchToFrame(String strFrameLoctor) throws Throwable { + WebElement allPagesFrame = null; + Log.info("Switching to default frame...."); + BrowserDriver.getCurrentDriver().switchTo().defaultContent(); + boolean isFrameVisible = false; + Log.info("Started finding visible frame...."); + for (WebElement frame : BrowserDriver.getCurrentDriver().findElements(By.cssSelector(strFrameLoctor))) { + //System.out.println(frame.getAttribute("src")); + if (frame.isDisplayed()) { + allPagesFrame = frame; + isFrameVisible = true; + Log.info("Visible frame found, exiting loop"); + break; + } + } + if (!isFrameVisible) { + TestCase.fail("No frames are visible hence not switching to frame"); + } + //Waits till the "Loading.." text disappears + BrowserDriver.getCurrentDriver().switchTo().frame(allPagesFrame); + Log.info("Switched to Third level Tab continuing...."); + } + + public void selectByVisibleText(String locator, String element, String value, int timeout) throws Exception { + WebElement ele = getWebElementObject(locator, element); + waitForObjectToLoad(ele); + Wait(timeout); + if (ele.isDisplayed()) { + Select list = new Select(ele); + list.selectByVisibleText(value); + Log.info("Selected '" + value + "' from dropdown ''" + locator + "=" + element + "'"); + } else { + Exception error = new Exception(element); + Log.error("Current page does not contain element ''" + locator + "=" + element + "'"); + String Str = new String(error.getMessage()); + Log.error("Error Message :" + Str.substring(1, 240)); + throw error; + } + } +} + + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/SpreadsheetUtils.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/SpreadsheetUtils.java new file mode 100755 index 000000000..69ad910f7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/SpreadsheetUtils.java @@ -0,0 +1,235 @@ +package com.rl.qa.utils; + +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import static junit.framework.Assert.assertTrue; + +public class SpreadsheetUtils { + + + // IWMS spreadsheet file. + private File file; + + // The one and only sheet expected from the Excel workbook. + private Sheet sheet; + + + + public String getCellValue(String colHeader,int rowNum) { + int numberOfCells = 0; + int colIndex = 0; + String cellValue = ""; + Iterator rowIterator = this.sheet.rowIterator(); + while (rowIterator.hasNext()) + { + Row headerRow = (Row) rowIterator.next(); + numberOfCells = headerRow.getPhysicalNumberOfCells(); + for(int i=0;i -1); + + String suffix = file.getName().substring(dot); + + if (suffix.equalsIgnoreCase(".xls")) { + return ".xls"; + } else if (suffix.equalsIgnoreCase(suffix)) { + return ".xlsx"; + } else { + String msg = String.format( + "File '%s' is not of a support type ['xls','xlsx]!", + file.getName() + ); + + throw new IllegalStateException(msg); + } + } + + private Sheet getSheet(File spreadsheet) throws IOException { + String suffix = getFileSuffix(spreadsheet); + FileInputStream inputStream = new FileInputStream(spreadsheet); + if (suffix.equals(".xlsx")) { + XSSFWorkbook book = new XSSFWorkbook(inputStream); + XSSFSheet sheet = book.getSheetAt(0); + + return sheet; + } else { + HSSFWorkbook book = new HSSFWorkbook(inputStream); + HSSFSheet sheet = book.getSheetAt(0); + + return sheet; + } + } + + + /** + * Create instance given the spreadsheet file. + * + * @param spreadsheet - file containing an IWMS spreadsheet + */ + public SpreadsheetUtils(File spreadsheet) throws IOException { + this.file = spreadsheet; + this.sheet = this.getSheet(spreadsheet); + } + + public static void main(String args[]){ + try{ + SpreadsheetUtils obj = new SpreadsheetUtils(new File("C:/Users/RLE0239/Desktop/Sales.xls")); + System.out.println(System.getProperty("user.dir")); + System.out.println(obj.getCellValue("Sales Group", 5)); + System.out.println(obj.getCellValue("Currency Type",4)); + System.out.println(obj.getCellValue("Currency Type",6)); + }catch(Exception e){ + + } + + } + + public String getDateCellValue(String colHeader,int rowNum) { + int numberOfCells = 0; + int colIndex = 0; + String cellValue = ""; + Iterator rowIterator = this.sheet.rowIterator(); + while (rowIterator.hasNext()) + { + Row headerRow = (Row) rowIterator.next(); + numberOfCells = headerRow.getPhysicalNumberOfCells(); + for(int i=0;i colIndex = new ArrayList<>(); + String cellValue = ""; + int headerCount = 0; + Iterator rowIterator = this.sheet.rowIterator(); + while (rowIterator.hasNext()) + { + Row headerRow = (Row) rowIterator.next(); + numberOfCells = headerRow.getPhysicalNumberOfCells(); + for(int i=0;i1){ + System.out.println("Same header name is present more than one: "+headerCount); + }else if(headerCount==0){ + System.out.println("Same header name is not present "+headerCount); + } + + String value = ""; + for(int i=0;iJan Papousek + * + * @see Extending Selenium 2.0 + * WebDriver to Support AJAX + */ +public class StaleReferenceAwareFieldDecorator extends DefaultFieldDecorator { + private final int numberOfTries; + /** + * Creates a new instance of the decorator + * + * @param factory + * locator factory + * @param numberOfTries + * number of tries to locate element + */ + public StaleReferenceAwareFieldDecorator(ElementLocatorFactory factory, int numberOfTries) { + super(factory); + this.numberOfTries = numberOfTries; + } + + @Override + protected WebElement proxyForLocator(ClassLoader loader, ElementLocator locator) { + InvocationHandler handler = new StaleReferenceAwareElementLocator(locator); + WebElement proxy = (WebElement) Proxy.newProxyInstance(loader, new Class[] { WebElement.class, + WrapsElement.class }, handler); + return proxy; + } + + private class StaleReferenceAwareElementLocator extends LocatingElementHandler { + private final ElementLocator locator; + public StaleReferenceAwareElementLocator(ElementLocator locator) { + super(locator); + this.locator = locator; + } + public Object invoke(Object object, Method method, Object[] objects) throws Throwable { + WebElement element = null; + for (int i = 0; i < numberOfTries; i++) { + element = locator.findElement(); + if ("getWrappedElement".equals(method.getName())) { + return element; + } + try { + return invokeMethod(method, element, objects); + } catch (StaleElementReferenceException ignored) { + } + } + throw new RuntimeException("Cannot invoke " + method.getName() + " on element " + element + + ". Cannot find it"); + } + private Object invokeMethod(Method method, WebElement element, Object[] objects) throws Throwable { + try { + return method.invoke(element, objects); + } catch (InvocationTargetException e) { + throw e.getCause(); + } catch (IllegalArgumentException e) { + throw e.getCause(); + } catch (IllegalAccessException e) { + throw e.getCause(); + } + } + } +} \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/ThreadPool.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/ThreadPool.java new file mode 100755 index 000000000..0acd8296c --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/utils/ThreadPool.java @@ -0,0 +1,152 @@ +package com.rl.qa.utils; + +import java.util.concurrent.*; + +public class ThreadPool { + private static ExecutorService executorService = null; + + private static ExecutorService getExecutorService() { + if (executorService == null) { + executorService = Executors.newCachedThreadPool(); + } + + return executorService; + } + + /** + * Executes the specified runnable in a thread from a thread pool. + */ + public static void execute(Runnable command) { + ExecutorService es = getExecutorService(); + + es.execute(command); + } + + /** + * Executes the specified runnable in a thread from a thread pool. + * + * @returns a handle to the running task + */ + public static Future submit(Runnable command) { + ExecutorService es = getExecutorService(); + + Future f = es.submit(command); + + return f; + } + + /** + * Submits a value-returning task for execution and returns a Future + * representing the pending results of the task. + * + * If you would like to immediately block waiting for a task, you + * can use constructions of the form + * + * result = exec.submit(aCallable).get(); + * + * @param task - the task to submit + * + * @return a Future representing pending completion of the task + */ + public static Future submit(Callable task) { + ExecutorService es = getExecutorService(); + + Future f = es.submit(task); + + return f; + } + + private static ScheduledExecutorService scheduledExecutorService = null; + + private static ScheduledExecutorService createScheduledExecutorService() { + if (scheduledExecutorService == null) { + scheduledExecutorService = Executors.newScheduledThreadPool(1); + } + + return scheduledExecutorService; + } + + /** + * Creates and executes a ScheduledFuture that becomes enabled after the given delay. + * + * @param callable - the task to execute + * @param delay - the time to wait before executing the task + * @param unit - the time units of the delay argument + * + * @return a Future that can be used to extract result or cancel + */ + public static ScheduledFuture schedule( + Callable callable, + long delay, + TimeUnit unit + ) { + return createScheduledExecutorService().schedule(callable, delay, unit); + } + + /** + * Creates and executes a one-shot action after waiting for the specified delay. + * + * @param command - the task to execute + * @param delay - the time to wait before executing the task + * @param unit - the time units of the delay argument + * + * @return a Future representing pending completion of the task, and whose get() + * method will return null upon completion + */ + public static ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + return createScheduledExecutorService().schedule(command, delay, unit); + } + + /** + * Creates and executes a periodic action that becomes enabled first after the + * given initial delay, and subsequently with the given period; that is executions + * will commence after initialDelay then initialDelay+period, then + * initialDelay + 2 * period, and so on. If any execution of the task encounters + * an exception, subsequent executions are suppressed. Otherwise, the task will + * only terminate via cancellation or termination of the executor. + * + * @param command - the task to execute + * @param initialDelay - the time to wait before the first execution + * @param period - the time to wait before subsequent executions without + * concern with the completion of prior executions + * @param unit - the time units of the initialDelay and period arguments + * + * @return a future representing pending completion of the task, and whose get() + * method will throw an exception upon cancellation + */ + public static ScheduledFuture scheduleAtFixedRate( + Runnable command, + long initialDelay, + long period, + TimeUnit unit + ) { + return createScheduledExecutorService(). + scheduleAtFixedRate(command, initialDelay, period, unit); + } + + /** + * Creates and executes a periodic action that becomes enabled first after the + * given initial delay, and subsequently with the given delay between the termination + * of one execution and the commencement of the next. If any execution of the task + * encounters an exception, subsequent executions are suppressed. Otherwise, the + * task will only terminate via cancellation or termination of the executor. + * + * @param command - the task to execute + * @param initialDelay - the time to wait before the first execution + * @param delay - the time to wait after termination of one execution and + * start of subsequent executions + * @param unit - the time units of the initialDelay and delay arguments + * + * @return a future representing pending completion of the task, and whose get() + * method will throw an exception upon cancellation + */ + public static ScheduledFuture scheduleWithFixedDelay( + Runnable command, + long initialDelay, + long delay, + TimeUnit unit + ) { + return createScheduledExecutorService(). + scheduleWithFixedDelay(command, initialDelay, delay, unit); + } +} \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CFTViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CFTViews.java new file mode 100755 index 000000000..ee236896f --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CFTViews.java @@ -0,0 +1,488 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.util.Random; +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0097 on 21-06-2016. + */ +public class CFTViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + public static WebElement PagesFrame; + public static String stackName=""; + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + public static void clickOnWorkZoneLink(){ + try { + Thread.sleep(3000); + SeleniumUtil.waitForElementIsClickable("id", "workZoneNew",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id", "workZoneNew", SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnWorkZoneLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOntheLink(String strLink){ + try { + Thread.sleep(2000); + SeleniumUtil.waitForElementIsClickable("paritallinktext", strLink, 10, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("paritallinktext", strLink, SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOntheLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnLink(String strLink){ + try { + SeleniumUtil.getFrameIndex("linktext", strLink); + SeleniumUtil.waitForElementIsClickable("linktext", strLink, 10, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext", strLink, SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOntheCssselectorField(String strcssselectorField){ + try { + SeleniumUtil.click("cssselector", strcssselectorField, SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOntheCssselectorField"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectBlueprintAndClickOnLaunchButton(String strBlueprint){ + try { + SeleniumUtil.click("cssselector", "li[title='"+strBlueprint+"']", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("cssselector", ".btn.pull-left.btn-primary.launchBtn.launchBtnMargin", SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectBlueprintAndClickOnLaunchButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnOKButton(String strButton){ + try { + SeleniumUtil.click("xpath", ".//button[./text()='"+strButton+"']", SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(5000); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnOKButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterStackName(String strStackName){ + try { + SeleniumUtil.type("id", "cftInput",strStackName, SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterStackName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnButtonButton(){ + try { + SeleniumUtil.waitForElementIsClickable("cssselector", "input[value='Submit']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("cssselector", "input[value='Submit']", SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnButtonButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyStackName(String strStackName,String strStatus){ + try { + Thread.sleep(5000); + SeleniumUtil.waitForElementVisibilityOf("cssselector", "div[data-stackname='" + strStackName + "']", 10, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitUntilElementContainsText("cssselector","div[data-stackname='"+strStackName+"'] span[class='stackStatus']",strStatus,200,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyStackName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnMoreInfoofInstanceCard(String strCardName){ + try { + SeleniumUtil.click("xpath", ".//span[@data-original-title='"+strCardName+"']/parent::div/following-sibling::div[1]/div/span/a", SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnMoreInfoofInstanceCard"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void getIPAddress(String strCardName){ + try { + String IPAddress = SeleniumUtil.getTextValue("xpath", ".//span[@data-original-title='"+strCardName+"']/parent::div/following-sibling::div[2]/div/span[1]", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.Log.info("IP Address :"+IPAddress); + } + catch(Exception ex){ + BaseView.takeScreenshot("getIPAddress"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnConfirmatinButton(){ + try { + SeleniumUtil.click("cssselector", "#launchResultContainer > div > div > div.modal-footer > button", SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(2000); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnConfirmatinButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void seeDashboard(){ + try { + SeleniumUtil.waitForElementIsClickable("id", "workzone", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitUntilElementNotContainsText("id", "workzone","WORKZONE", 8,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("seeDashboard"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void expendTheTree(String strTreeHead){ + try { + if(SeleniumUtil.waitForElementVisibilityOf("xpath", ".//a[text()='"+strTreeHead+"']/ancestor::li/span[@class='expand-collapse click-expand fa fa-angle-right']", 2, SeleniumUtilities.OBJWAITTIMEOUT)) { + SeleniumUtil.waitForElementIsClickable("paritallinktext", strTreeHead, 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("paritallinktext", strTreeHead, SeleniumUtilities.OBJWAITTIMEOUT); + } + } + catch(Exception ex){ + BaseView.takeScreenshot("expendTheTree"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnTrack(){ + try { + SeleniumUtil.click("id", "trackNew",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnTrack"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnLineChartNotifications(String strLabel){ + try { +// SeleniumUtil.getFrameIndex("xpath", ".//a[contains(./text(),'"+strLabel+"')]/ancestor::li/span[@class='icon fa fa-line-chart']"); + SeleniumUtil.click("xpath", ".//a[contains(./text(),'"+strLabel+"')]/ancestor::li/span[@class='icon fa fa-line-chart']",SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.switchTodefaultContent(); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnLineChartNotifications"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnFileNotifications(String strLabel){ + try { +// SeleniumUtil.getFrameIndex("xpath", ".//a[contains(./text(),'"+strLabel+"')]/ancestor::li/span[@class='icon fa fa-lg fa-fw fa-files-o']"); + SeleniumUtil.click("xpath", ".//a[contains(./text(),'"+strLabel+"')]/ancestor::li/span[@class='icon fa fa-lg fa-fw fa-files-o']",SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.switchTodefaultContent(); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnFileNotifications"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnDesktopNotifications(String strLabel){ + try { + SeleniumUtil.click("xpath", ".//a[contains(./text(),'"+strLabel+"')]/ancestor::li/span[@class='icon fa fa-fw fa-1x fa-desktop']",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnDesktopNotifications"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void getPrivateIPAddress(String strCardName){ + try { + String IPAddress = SeleniumUtil.getTextValue("cssselector", "span[class='ip-cell-private']", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.Log.info("IP Address :"+IPAddress); + } + catch(Exception ex){ + BaseView.takeScreenshot("getPrivateIPAddress"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyPublicIPAddress(String strCardName){ + try { + String IPAddress = SeleniumUtil.getTextValue("xpath", ".//*[./text()='"+strCardName+"']/parent::div/following-sibling::div[1]/span[@class='ip-cell-public']", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.Log.info("Public IP Address :"+IPAddress); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyPublicIPAddress"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void switchToFrame() throws Throwable { + SeleniumUtil.Log.info("Switching to default frame...."); + BrowserDriver.getCurrentDriver().switchTo().defaultContent(); + boolean isFrameVisible = false; + SeleniumUtil.Log.info("Started finding visible frame...."); + for (WebElement frame : BrowserDriver.getCurrentDriver().findElements(By.tagName("iframe"))) { + //System.out.println(frame.getAttribute("src")); + if (frame.isDisplayed()) { + PagesFrame = frame; + isFrameVisible = true; + SeleniumUtil.Log.info("Visible frame found, exiting loop"); + break; + } + } + if (!isFrameVisible) { + fail("No frames are visible hence not switching to frame"); + } + //Waits till the "Loading.." text disappears + BrowserDriver.getCurrentDriver().switchTo().frame(PagesFrame); + SeleniumUtil.Log.info("Switched to Third level Tab continuing...."); + } + + public static void selectOrg(String orgName) { + try { + SeleniumUtil.selectByVisibleText("id","selectOrgName",orgName,SeleniumUtil.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnConfigStackParaLink(String configStackPara) { + try { + SeleniumUtil.click("linktext",configStackPara,SeleniumUtil.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnConfigStackParaLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterStackPara(String stackPara, String webEleAttribute) { + try { + SeleniumUtil.clear("xpath","//input[@data-cftparameter-name='"+webEleAttribute+"']",SeleniumUtil.OBJWAITTIMEOUT); + SeleniumUtil.type("xpath","//input[@data-cftparameter-name='"+webEleAttribute+"']",stackPara,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterStackPara"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterInstanceUserName(String instanceUserName) { + try { + SeleniumUtil.type("cssselector",".cftResourceInput.form-control.cftResourceUsernameInput",instanceUserName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterStackUserName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnBlueprintType(String blueprintType) { + try { + SeleniumUtil.click("cssselector",".fa.fa-fw.ng-scope.fa-plus-circle",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnBlueprintType"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterUniqueStackName(String uniqueStackName) { + try { + int max = 10000; + int min = 1000; + Random r = new Random(); + int ranNumber = r.nextInt((max - min) + 1) + min; + stackName = "RL" + ranNumber; + SeleniumUtil.type("id","cftInput",uniqueStackName,SeleniumUtilities.OBJWAITTIMEOUT); + System.out.println(stackName); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnBlueprintType"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void refreshCFTStackPage() { + try { + for (int i = 0; i < 10; i++) { + if (SeleniumUtil.verifyTextValue("cssselector", ".stackStatus.orange", "CREATE_IN_PROGRESS", SeleniumUtilities.OBJWAITTIMEOUT)) { + Thread.sleep(3000); + SeleniumUtil.click("xpath", ".//*[@id='cloudFormationPage']//button", SeleniumUtilities.OBJWAITTIMEOUT); + } + else{ + break; + } + } + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnBlueprintType"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyStatusCreateInProgress(String stackName) { + try { + SeleniumUtil.waitUntilElementContainsText("cssselector",".stackStatus.orange","CREATE_IN_PROGRESS",SeleniumUtilities.OBJWAITTIMEOUT); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 50); + wait.until(ExpectedConditions.textToBePresentInElement(By.tagName("*"),"CREATE_IN_PROGRESS")); + SeleniumUtil.waitForElementVisibilityOf("cssselector",".stackStatus.orange", 8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("cssselector",".stackStatus.orange","CREATE_IN_PROGRESS",SeleniumUtilities.OBJWAITTIMEOUT));{ + logger.info("Verified status : CREATE_IN_PROGRESS"); + } + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyStatusCreateInProgress"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyStatusCreateComplete() { + try { + SeleniumUtil.waitUntilElementContainsText("cssselector",".stackStatus.green","CREATE_COMPLETE",SeleniumUtilities.OBJWAITTIMEOUT); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 50); + wait.until(ExpectedConditions.textToBePresentInElement(By.tagName("*"),"CREATE_COMPLETE")); + SeleniumUtil.waitForElementVisibilityOf("cssselector",".stackStatus.green", 8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("cssselector",".stackStatus.green","CREATE_COMPLETE",SeleniumUtilities.OBJWAITTIMEOUT));{ + logger.info("Verified status : CREATE_COMPLETE"); + } + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyStatusCreateComplete"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickonTheLinkSaid(String strLinkSaid) { + try { + SeleniumUtil.click("xpath", ".//*[@id='myTab3']/li[1]/a", 15); + + } + catch(Exception ex){ + BaseView.takeScreenshot("clickLinkSaid"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickonCloudformationTab(String strCloudForamtion) { + try { + SeleniumUtil.click("xpath", "//*[contains(text(),'"+strCloudForamtion+"')]", 15); + + } + catch(Exception ex){ + BaseView.takeScreenshot("clickLinkSaid"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void VerifyCloudFormationBlueprint(String strCloudForamtionBP) { + try { + Thread.sleep(1000); + assertTrue(SeleniumUtil.verifyTextValue("xpath", "//li[@class='card-text-overflow'][@title='"+strCloudForamtionBP+"']", strCloudForamtionBP, SeleniumUtilities.OBJWAITTIMEOUT)); + System.out.println("CloudBlueprint is Created"); + + } + catch(Exception ex){ + BaseView.takeScreenshot("clickLinkSaid"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnBlueprints() { + try { + SeleniumUtil.click("xpath", ".//*[@id='myTab3']/li[1]/ul/li[2]/a", 15); + + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnBlueprints"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void VerifySoftwareStackBlueprint(String strSoftwareStackBP) { + try { + Thread.sleep(1000); + assertTrue(SeleniumUtil.verifyTextValue("xpath", "//li[@class='card-text-overflow'][@title='"+strSoftwareStackBP+"']", strSoftwareStackBP, SeleniumUtilities.OBJWAITTIMEOUT)); + System.out.println("SoftwareStack BP is Created"); + + } + catch(Exception ex){ + BaseView.takeScreenshot("verifySoftwarestackBP"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + + + + + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ChefServerSetupViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ChefServerSetupViews.java new file mode 100755 index 000000000..71e43603b --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ChefServerSetupViews.java @@ -0,0 +1,269 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import cucumber.api.java.eo.Se; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.LocalFileDetector; +import org.openqa.selenium.remote.RemoteWebElement; +import org.openqa.selenium.support.PageFactory; + +import java.io.File; +import java.util.logging.Logger; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 20-07-2016. + */ +public class ChefServerSetupViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + public static void enterServerName(String chefServerName) { + try{ + SeleniumUtil.waitForElementIsClickable("id","configname",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","configname",chefServerName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("typeServerName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterUserName(String userName) { + try{ + SeleniumUtil.waitForElementIsClickable("id","loginname",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","loginname",userName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("typeUserName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterURL(String url) { + try{ + SeleniumUtil.waitForElementIsClickable("id","url",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","url",url,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("typeURL"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + +// public static void clickOnPemFileBrowse() { +// try{ +// String path = new String(new File(".").getCanonicalPath() + "\\src\\test\\resources\\Upload\\mycatqa.pem"); +//// System.out.println(path); +//// logger.info(path); +// WebDriver driver=SeleniumUtil.getWebDriver(); +// driver.findElement(By.xpath("//input[@id='userpemfile']")).sendKeys(path); +// } +// catch(Exception ex){ +// BaseView.takeScreenshot("clickOnPemFileBrowse"); +// SeleniumUtil.Log.info("Error :" + ex.getMessage()); +// fail(ex.getMessage()); +// } +// } +// +// public static void clickOnKnifeBrowse() { +// try{ +// Thread.sleep(5000); +// String path = new String(new File(".").getCanonicalPath() + "\\src\\test\\resources\\Upload\\knife.rb"); +//// System.out.println(path); +//// logger.info(path); +// WebDriver driver=SeleniumUtil.getWebDriver(); +// driver.findElement(By.xpath("//input[@id='kniferbfile']")).sendKeys(path); +// } +// catch(Exception ex){ +// BaseView.takeScreenshot("clickOnPemFileBrowse"); +// SeleniumUtil.Log.info("Error :" + ex.getMessage()); +// fail(ex.getMessage()); +// } +// } + + public static void BrowsePemFileForChefServer() { + try{ + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.id("userpemfile")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/mycatqa.pem"); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); +// element.sendKeys(path); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnPemFileBrowse"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void BrowseKnifeFileForChefServer() { + try{ + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.id("kniferbfile")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/knife.rb"); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); +// element.sendKeys(path); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnPemFileBrowse"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + public static void chefServerEditButton(String cherServerName,String Edit ) { + try{ + Thread.sleep(1000); + SeleniumUtil.waitForElementIsClickable("xpath",".//*[@id='envtable']//td[text()='"+cherServerName+"']/following-sibling::td//*[@title='"+Edit+"']",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath",".//*[@id='envtable']//td[text()='"+cherServerName+"']/following-sibling::td//*[@title='"+Edit+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("chefServerEditButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clearNameField() { + try{ + SeleniumUtil.waitForElementIsClickable("id","configname",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.clear("id","configname",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clearNameField"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyChefServerName(String chefServerName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+chefServerName+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+chefServerName+"']",chefServerName,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified created chef server:"+chefServerName); +// } else { +// logger.info("Chef Server not found:" +chefServerName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyChefServerName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifySelectOrgISDisabled() { + try { + SeleniumUtil.waitForElementVisibilityOf("id","s2id_orgname",5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb=SeleniumUtil.getElement("id","s2id_orgname",SeleniumUtilities.OBJWAITTIMEOUT); + String actClassValOfElement=wb.getAttribute("class"); + String expClassValWhenEleIsDisabled="select2-container select2-container-disabled chooseOrganization width-100"; + assertTrue(actClassValOfElement.equals(expClassValWhenEleIsDisabled)); + logger.info("Select Organization is disbled"); +// } else { +// logger.info("Element is enabled"); + } catch (Exception ex) { + BaseView.takeScreenshot("verifySelectOrgISDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } } + + public static void verifyChefServerIsDeleted(String chefServerName) { + try { +// SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+chefServerName+"']/following-sibling::td[2]", 1, SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='"+chefServerName+"']")); { + logger.info(chefServerName+" does not exists : deleted"); +// } else { +// logger.info(chefServerName+" does not exists : deleted"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyChefServerIsDeleted"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyServerDetails(String chefServerName, String chefUserName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+chefServerName+"']/../td[text()='"+chefUserName+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+chefServerName+"']/../td[text()='"+chefUserName+"']",chefUserName,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Chef server" +chefServerName+" exists with :"+chefUserName); +// } else { +// logger.info("Chef server" +chefServerName+" does not exists with :"+chefUserName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("chefUserName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void uploadKnifeFile(String fileName) { + try{ + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.id("kniferbfile")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/jagadeesh12_ChefServerFile"+fileName); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnPemFileBrowse"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void uploadPemFile(String fileName) { + try{ + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.id("userpemfile")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/jagadeesh12_ChefServerFile/"+fileName); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); + } + catch(Exception ex){ + BaseView.takeScreenshot("uploadPemFile"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + public static void selectTheOrg(String strOrgname) { + try{ + //SeleniumUtil.waitForElementIsClickable("id","loginname",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "//span[text()='Select an Organization']",SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//div[text()='"+strOrgname+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } +} + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigBlueprintForOSImageUsingProAWSViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigBlueprintForOSImageUsingProAWSViews.java new file mode 100755 index 000000000..66ab31f2f --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigBlueprintForOSImageUsingProAWSViews.java @@ -0,0 +1,86 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 23-09-2016. + */ +public class ConfigBlueprintForOSImageUsingProAWSViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + public static void verifyChooseOSIsDisabled() { + try { + WebElement wb=SeleniumUtil.getElement("id","instanceOS",SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(wb.isEnabled()); + logger.info("Choose Operating System is disabled"); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyElementIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyChooseProviderIsDisabled() { + try { + WebElement wb=SeleniumUtil.getElement("id","providerId",SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(wb.isEnabled()); + logger.info("Choose Choose Provider is disabled"); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyChooseProviderIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyChooseAvailableImages() { + try { + WebElement wb=SeleniumUtil.getElement("id","imageId",SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(wb.isEnabled()); + logger.info("Choose Available Images is disabled"); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyChooseAvailableImages"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyChooseOrgIsDisabled() { + try { + WebElement wb=SeleniumUtil.getElement("id","",SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(wb.isEnabled()); + logger.info("Choose Organization is disabled"); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyChooseOrgIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyLaunchButtonISDisplayed() { + try { + assertTrue(SeleniumUtil.verifyTextValue("id","blueprintLaunch","Launch Blueprint",SeleniumUtilities.OBJWAITTIMEOUT)); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyChooseOrgIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigBlueprintForSSTempUsingProAWSViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigBlueprintForSSTempUsingProAWSViews.java new file mode 100755 index 000000000..e71005cf4 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigBlueprintForSSTempUsingProAWSViews.java @@ -0,0 +1,170 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 10-09-2016. + */ +public class ConfigBlueprintForSSTempUsingProAWSViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + public static void verifyBlueprintInWorkZone(String blueprintName, String pageName) { + try { + assertTrue(SeleniumUtil.verifyTextValue("xpath", "//*[text()='"+blueprintName+"']",blueprintName,SeleniumUtilities.OBJWAITTIMEOUT)); + logger.info("Verified Blueprint in "+pageName+" "+blueprintName); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyBlueprintInWorkZone"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickOnMoreInfo(String moreInfo, String blueprintName) { + try { + SeleniumUtil.click("cssselector","i[title='More Info']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnMoreInfo"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickOnClose() { + try { + SeleniumUtil.click("xpath",".//*[@id='instanceLogsPage']//button",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnCloseInstanceLogPopup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void selectBlueprint(String blueprintName) { + try { + SeleniumUtil.click("xpath","//*[text()='"+blueprintName+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectBlueprint"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnCopyBlueprint() { + try { + SeleniumUtil.click("cssselector","button[title='Copy Blueprint']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnCopyBlueprint"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void selectParametersOnPopupWindow(String name, String idOfElement) { + try { + SeleniumUtil.selectByVisibleText("id",idOfElement,name,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectParametersOnPopupWindow"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickOnSave(String buttonText) { + try { + SeleniumUtil.click("xpath","//*[text()='"+buttonText+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnSaveOnPopup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnEnv(String proName, String envName) { + try { + SeleniumUtil.click("xpath","//div[span[text()='"+proName+"']]//*[text()='"+envName+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnSaveOnPopup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnDeleteBlueprint(String buttonTitle) { + try { + SeleniumUtil.click("cssselector","button[title='Remove Blueprint']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnDelete"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyBlueprintDeleted(String blueprintName) { + try { + assertFalse(SeleniumUtil.isElementExist("xpath", "//*[text()='"+blueprintName+"']")); + logger.info(blueprintName+" does not exists : deleted"); + + } catch (Exception ex) { + BaseView.takeScreenshot("verifyBlueprintDeleted"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnEditBlueprintButton(String buttonTitle, String blueprintName) { + try { + SeleniumUtil.click("xpath","//li[@title='"+blueprintName+"']/following-sibling::button[@title='"+buttonTitle+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyBlueprintDeleted"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnSettings() { + try { + SeleniumUtil.waitForElementIsClickable("id","settingsNew",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id","settingsNew",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnSettings"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void deleteBlueprint(String title) { + try { + SeleniumUtil.click("cssselector","span[title='"+title+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("deleteBlueprint"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnDeleteOnConfirmationPopup() { + try { + SeleniumUtil.click("cssselector",".btn.cat-btn-delete",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnDeleteOnConfirmationPopup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigureNexusServerViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigureNexusServerViews.java new file mode 100755 index 000000000..d75af7c08 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigureNexusServerViews.java @@ -0,0 +1,62 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 09-08-2016. + */ +public class ConfigureNexusServerViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + public static void verifyNexusServerName(String nexusServerName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+nexusServerName+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//*[text()='"+nexusServerName+"']",nexusServerName,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info(nexusServerName+" is available"); +// } else { +// logger.info(nexusServerName+" is not available"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyNexusServerName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyNexusServerInfo(String nexusServerName, String nexusServerDetails) { + try { +// SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+nexusServerName+"']/../*[text()='"+nexusServerDetails+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//*[text()='"+nexusServerName+"']/../*[text()='"+nexusServerDetails+"']",nexusServerDetails,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info(nexusServerName+" is available with "+nexusServerDetails); +// } else { +// logger.info(nexusServerName+" is not available with "+nexusServerDetails); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyNexusServerName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectOrgInNexusConfigPage(String orgName) { + try { + SeleniumUtil.selectByVisibleText("id","orgname",orgName,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectOrgInNexusConfigPage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } +} + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigureProviderViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigureProviderViews.java new file mode 100755 index 000000000..1eec9fbdf --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigureProviderViews.java @@ -0,0 +1,353 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.LocalFileDetector; +import org.openqa.selenium.remote.RemoteWebElement; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.io.File; +import java.util.logging.Logger; + +import static junit.framework.TestCase.*; + +/** + * Created by RLE0372 on 02-08-2016. + */ +public class ConfigureProviderViews { + + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + public static void selectProviderType(String providerType) { + + try { + SeleniumUtil.selectByVisibleText("id","providertype",providerType,SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.waitForElementIsClickable("id","s2id_providertype",8, SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("id","s2id_providertype",SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("xpath",".//*[@id='select2-drop']//*[text()='"+providerType+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectProviderType"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickCredentialSelButton(String buttonID) { + try { + SeleniumUtil.waitForElementIsClickable("id",buttonID,8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.checkbox("id",buttonID,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickCredentialSelButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectOrg(String orgName) { + try { + //SeleniumUtil.waitForElementIsClickable("xpath","//label[contains(text(),'Organization')]/following-sibling::div",8, SeleniumUtilities.OBJWAITTIMEOUT); + //Thread.sleep(1000); +// SeleniumUtil.click("xpath","//span[text()='Select an Organization']",SeleniumUtilities.OBJWAITTIMEOUT); +// Thread.sleep(1000); + //SeleniumUtil.waitForElementIsClickable("xpath","//*[text()='"+orgName+"']",8, SeleniumUtilities.OBJWAITTIMEOUT); + //Thread.sleep(1000); +// SeleniumUtil.click("xpath","//div[text()='"+orgName+"']", SeleniumUtilities.OBJWAITTIMEOUT); + //select/option[@value='"+orgName+"']" +// Thread.sleep(2000); + SeleniumUtil.selectByVisibleText("id","orgname",orgName,SeleniumUtilities.OBJWAITTIMEOUT); + + } + catch(Exception ex){ + BaseView.takeScreenshot("selectOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void OrgSelct(String orgName) { + try { + SeleniumUtil.waitForElementIsClickable("xpath","//label[contains(text(),'Organization')]/following-sibling::div",8, SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(1000); + SeleniumUtil.click("xpath","//label[contains(text(),'Organization')]/following-sibling::div",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(1000); + //SeleniumUtil.waitForElementIsClickable("xpath","//*[text()='"+orgName+"']",8, SeleniumUtilities.OBJWAITTIMEOUT); + //Thread.sleep(1000); + SeleniumUtil.click("xpath","//select[@id='orgId']/option[text()='"+orgName+"']", SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectRegion(String region) { + try { + SeleniumUtil.selectByVisibleText("name","region","US West (N. California) | us-west-1",SeleniumUtilities.OBJWAITTIMEOUT); +// Thread.sleep(5000); +// SeleniumUtil.waitForElementIsClickable("xpath","(//span[text()='Select Region'])[2]",8, SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("xpath","(//span[text()='Select Region'])[2]",SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.waitForElementIsClickable("xpath","//option[contains(text(),'"+region+"')]",8, SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("xpath","//option[contains(text(),'"+region+"')]",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectRegion"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectKeyPair(String keyPair) { + try { + SeleniumUtil.selectByVisibleText("name","keyPairName",keyPair, SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.waitForElementIsClickable("xpath","//*[text()='Select Key Pair:']/following-sibling::div",8, SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("xpath","//*[text()='Select Key Pair:']/following-sibling::div",SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.waitForElementIsClickable("xpath","//*[text()='"+keyPair+"']",8, SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("xpath","//*[text()='"+keyPair+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectKeyPair"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void browsePemFileForProvider() { + try { + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.name("fileObject")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/bootstrapncal.pem"); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); +// element.sendKeys(path); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectKeyPair"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyProvidersName(String providerName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//*[contains(text(),'Azure')]", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitUntilElementContainsText("xpath","//*[contains(text(),'Azure')]",providerName,8,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyProvidersName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyMessage(String actMsg) { + try { + SeleniumUtil.waitUntilElementContainsText("xpath",".//*[contains(./text(),'"+actMsg+"')]",actMsg,SeleniumUtilities.OBJWAITTIMEOUT); + WebDriverWait wait = new WebDriverWait(BrowserDriver.getCurrentDriver(), 500); + wait.until(ExpectedConditions.textToBePresentInElement(By.tagName("*"), actMsg)); + SeleniumUtil.waitForElementVisibilityOf("xpath", "//*[contains(text(),'"+actMsg+"')]", 8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath",".//*[contains(./text(),'"+actMsg+"')]",actMsg,SeleniumUtilities.OBJWAITTIMEOUT));{ + logger.info("Verified : " +actMsg); + } +// else{ +// logger.info("Not Verified"+actMsg); +// } + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyProvidersName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + public static void browseAzurePemFile() { + try { + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.id("azurepem")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/rlcatalyst.pem"); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); +// element.sendKeys(path); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectKeyPair"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void browseAzurePrivateKeyFile() { + try { + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.id("azurekey")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/rlcatalyst.key"); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); +// element.sendKeys(path); + } + catch(Exception ex){ + BaseView.takeScreenshot("selectKeyPair"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void browseOpenStackPemFile(String openStackpemFile) { + try { + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.id("openstackinstancepem")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/"+ openStackpemFile); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); +// element.sendKeys(path); + } + catch(Exception ex){ + BaseView.takeScreenshot("browseOpenStackPemFile"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyProviderName(String providerName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+providerName+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//*[text()='"+providerName+"']",providerName,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified : "+providerName); +// } else { +// logger.info("Not verified:" +providerName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyProvideDetails"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifySelProviderTypeisDisabled() { + try { + SeleniumUtil.waitForElementVisibilityOf("id","s2id_providertype",5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb=SeleniumUtil.getElement("id","s2id_providertype",SeleniumUtilities.OBJWAITTIMEOUT); + String actClassValOfElement=wb.getAttribute("class"); + String expClassValWhenEleIsDisabled="select2-container select2-container-disabled chooseOrganization width-100"; + assertTrue(actClassValOfElement.equals(expClassValWhenEleIsDisabled));{ + logger.info("Select provider type is disbled"); +// } else { +// logger.info("Select provider type is enabled"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifySelProviderTypeIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } } + + public static void verifyCredentialsAccessKeyIsDisabled(String credentialsAccessKeys) { + try { + SeleniumUtil.waitForElementVisibilityOf("id",credentialsAccessKeys,5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb=SeleniumUtil.getElement("id",credentialsAccessKeys,SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(wb.isEnabled());{ + logger.info("Credentials Access Keys is enabled"); +// } else { +// logger.info("Credentials Access Keys is disabled"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyCredentialsAccessKeyisDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } } + + + public static void verifySelectOrgIsDisabled() { + try { + SeleniumUtil.waitForElementVisibilityOf("id","s2id_orgId",5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb=SeleniumUtil.getElement("id","s2id_orgId",SeleniumUtilities.OBJWAITTIMEOUT); + String actClassValOfElement=wb.getAttribute("class"); + String expClassValWhenEleIsDisabled="select2-container select2-container-disabled chooseOrganization width-100"; + assertTrue(actClassValOfElement.equals(expClassValWhenEleIsDisabled));{ + logger.info("Select organization type is disabled"); +// } else { +// logger.info("Select organization type is enabled"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifySelectOrgIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } } + + public static void verifySelectRegionIsDisabled() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath",".//*[@class='select2-container select2-container-disabled region chooseOrganization width-100 secretInfo']",5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb=SeleniumUtil.getElement("xpath",".//*[@class='select2-container select2-container-disabled region chooseOrganization width-100 secretInfo']",SeleniumUtilities.OBJWAITTIMEOUT); + String actClassValOfElement=wb.getAttribute("class"); + String expClassValWhenEleIsDisabled="select2-container select2-container-disabled region chooseOrganization width-100 secretInfo"; + assertTrue(actClassValOfElement.equals(expClassValWhenEleIsDisabled));{ + logger.info("Select region is disabled"); +// } else { +// logger.info("Select region is enabled"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifySelectRegionIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } } + + public static void verifySelKeyPairIsDisabled() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath","//*[@class='select2-container select2-container-disabled chooseOrganization width-100 keyvalue secretInfo']",5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb=SeleniumUtil.getElement("xpath","//*[@class='select2-container select2-container-disabled chooseOrganization width-100 keyvalue secretInfo']",SeleniumUtilities.OBJWAITTIMEOUT); + String actClassValOfElement=wb.getAttribute("class"); + String expClassValWhenEleIsDisabled="select2-container select2-container-disabled chooseOrganization width-100 keyvalue secretInfo"; + assertTrue(actClassValOfElement.equals(expClassValWhenEleIsDisabled));{ + logger.info("Select key pair is disabled"); +// } else { +// logger.info("Select key pair is enabled"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifySelKeyPairIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } } + + public static void verifyProviderInfo(String providerName, String providerInfo) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+providerName+"']/../*[text()='"+providerInfo+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//*[text()='"+providerName+"']/../*[text()='"+providerInfo+"']",providerInfo,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info(providerName+" is available with : "+providerInfo); +// } else { +// logger.info(providerName+" is not available with : "+providerInfo); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyProviderInfo"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectOrgInNewAWSPage(String orgName) { + try { + SeleniumUtil.selectByVisibleText("id","orgId",orgName,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectOrgInNewAWSPage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigurePuppetServerViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigurePuppetServerViews.java new file mode 100755 index 000000000..8885df3dd --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ConfigurePuppetServerViews.java @@ -0,0 +1,82 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.support.PageFactory; + +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 01-08-2016. + */ +public class ConfigurePuppetServerViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + public static void clickOnPuppetServerLink() { + try{ + SeleniumUtil.waitForElementIsClickable("linktext","Puppet Server",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext","Puppet Server",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch (Exception ex) + { + BaseView.takeScreenshot("clickOnPuppetServerLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterPuppetServerName(String puppetServerName) { + try{ + SeleniumUtil.waitForElementIsClickable("id","puppetservername",8,SeleniumUtil.OBJWAITTIMEOUT); + SeleniumUtil.type("id","puppetservername","",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch (Exception ex) + { + BaseView.takeScreenshot("enterPuppetServerName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterUserName(String userName) { + try{ + SeleniumUtil.waitForElementIsClickable("id","username",8,SeleniumUtil.OBJWAITTIMEOUT); + SeleniumUtil.type("id","username",userName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch (Exception ex) + { + BaseView.takeScreenshot("enterUserName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterHostName(String hostName) { + try{ + SeleniumUtil.waitForElementIsClickable("id","hostname",8,SeleniumUtil.OBJWAITTIMEOUT); + SeleniumUtil.type("id","hostname",hostName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch (Exception ex) + { + BaseView.takeScreenshot("enterHostName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterPuppetPassword(String password) { + try{ + SeleniumUtil.waitForElementIsClickable("id","puppetpassword",8,SeleniumUtil.OBJWAITTIMEOUT); + SeleniumUtil.type("id","puppetpassword",password,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch (Exception ex) + { + BaseView.takeScreenshot("enterPuppetPassword"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } +} + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelBGroupViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelBGroupViews.java new file mode 100755 index 000000000..13131cd64 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelBGroupViews.java @@ -0,0 +1,204 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 20-07-2016. + */ +public class CreateEditDelBGroupViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + public static void clickBGroupLink()throws InterruptedException { + try { + SeleniumUtil.waitForElementIsClickable("linktext", "Business Groups", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext","Business Groups",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickBGroupLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + public static void clickOnNewBGroup() { + try { + SeleniumUtil.waitForElementIsClickable("id","newProd", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id","newProd",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnNewBGroup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterBGroupName(String bGroupName) { + try { + SeleniumUtil.waitForElementIsClickable("id","productgroupname", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","productgroupname",bGroupName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterBGroupName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterOrgName(String org_Name) { + try { + SeleniumUtil.waitForElementIsClickable("xpath",".//*[@id='select2-drop']/div/input", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath",".//*[@id='select2-drop']/div/input",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterOrgName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + public static void clickOnEditBGroup(String bGroup) { + try { + SeleniumUtil.waitForElementIsClickable("xpath",".//*[@id='envtable']/tbody/tr/td[text()='"+bGroup+"']/../td/div/a",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath",".//*[@id='envtable']/tbody/tr/td[text()='"+bGroup+"']/../td/div/a",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnEditBGroup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clearField() { + try { + SeleniumUtil.waitForElementIsClickable("id","productgroupname",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.clear("id","productgroupname",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clearField"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterNewBGrpName(String newBGrpName) { + try { + SeleniumUtil.waitForElementIsClickable("id","productgroupname",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","productgroupname",newBGrpName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterNewBGrpName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void delEditedBGroup(String editedBGrp) { + try { + SeleniumUtil.waitForElementIsClickable("xpath",".//*[@id='envtable']/tbody/tr/td[text()='"+editedBGrp+"']/../td/div/button",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath",".//*[@id='envtable']/tbody/tr/td[text()='"+editedBGrp+"']/../td/div/button",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("delEditedBGroup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickOnOrgLinkInSettTree() { + try { + SeleniumUtil.waitForElementIsClickable("linktext","Organizations",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext","Organizations",SeleniumUtilities.OBJWAITTIMEOUT); + + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnOrgLinkInSettTree"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyAssignedOrg(String bGroup,String org) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//td[text()='"+bGroup+"']/../td[text()='"+org+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//td[text()='"+bGroup+"']/../td[text()='"+org+"']",org,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified assigned organization:"+org); +// } else { +// logger.info("Assigned Organization not found:" +org); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyAssignedOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void verifyCreatedBGroup(String businessGroup) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+businessGroup+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+businessGroup+"']",businessGroup,SeleniumUtilities.OBJWAITTIMEOUT)); + logger.info("Verified created Business Group :"+businessGroup); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyCreatedOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyEditedBGroup(String editedBGroup) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath",".//*[@id='envtable']//*[text()='"+editedBGroup+"']",8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.waitUntilElementContainsText("xpath",".//*[@id='envtable']//*[text()='"+editedBGroup+"']",editedBGroup,5,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified edited Business Group :" +editedBGroup); +// } else { +// logger.info("Edited Business Group : "+ editedBGroup+ " does not exist"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEditedBGroup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyDeletedBGroup(String bGroup) { + try { +// SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+bGroup+"']", 1, SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='"+bGroup+"']")); { + logger.info("Business Group does not exists : Deleted"); +// } else { +// logger.info("Business Group does not exists : Business Group deleted"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDeletedBGroup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectBusinessGroup(String orgName) { + try { + SeleniumUtil.click("xpath","//span[text()='Select an Organization']",SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//div[text()='"+orgName+"']",SeleniumUtilities.OBJWAITTIMEOUT); + //SeleniumUtil.selectByVisibleText("id","orgname",orgName,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectBusinessGroup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } +} + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelDesignerViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelDesignerViews.java new file mode 100755 index 000000000..16b2566a5 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelDesignerViews.java @@ -0,0 +1,383 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.CreateEditDelDesignerSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.apache.log4j.Logger; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.PageFactory; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by rle0346 on 3/8/16. + */ +public class CreateEditDelDesignerViews { + private static final Logger logger = Logger.getLogger(CreateEditDelDesignerSteps.class.getName()); + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + + public static void clickOnUsersSetupLink(String strUserSetupLink) { + try { + SeleniumUtil.waitForElementIsClickable("xpath", "//a[text()='" + strUserSetupLink + "']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "//a[text()='" + strUserSetupLink + "']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnUsersSetupLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + public static void clickOnUsersLink(String strUserLink) { + try { + SeleniumUtil.waitForElementIsClickable("xpath", "//a[text()='" + strUserLink + "']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "//a[text()='" + strUserLink + "']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnUsersLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + + } + + + public static void clickOnNewButton() { + try { + SeleniumUtil.waitForElementIsClickable("id", "newUser", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id", "newUser", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnNewButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterLoginName(String strDesignerName) { + try { + //SeleniumUtil.waitForElementVisibilityOf("loginname", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id", "loginname", strDesignerName, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("enterLoginName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterEmailAddress(String strEmailAddress) { + try { + //SeleniumUtil.waitForElementVisibilityOf("loginname", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.clear("id" ,"email", 8); + SeleniumUtil.type("id", "email", strEmailAddress, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("enterEmailAddress"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterPassword(String strPassword) { + try { + //SeleniumUtil.waitForElementVisibilityOf("loginname", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id", "password", strPassword, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("enterPassword"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterConfirmPassword(String strconfPassword) { + try { + //SeleniumUtil.waitForElementVisibilityOf("loginname", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id", "cnfPassword", strconfPassword, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("enterConfirmPassword"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + + } + + + public static void selectOrganization(String strOrganization) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//span[text()='All']", 8); + SeleniumUtil.click("xpath", "//span[text()='All']", 8); + SeleniumUtil.waitForElementVisibilityOf("xpath", "//div[text()='"+strOrganization+"']", 8); + SeleniumUtil.click("xpath", "//div[text()='"+strOrganization+"']", 8); + + } catch (Exception ex) { + BaseView.takeScreenshot("selectOrganization"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + + } + + public static void selectRole(String strRole) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//label[text()='" + strRole + "']/input/../i", 8); + SeleniumUtil.click("xpath", "//label[text()='" + strRole + "']/input/../i", 8); + + } catch (Exception ex) { + BaseView.takeScreenshot("selectRole"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + + } + + public static void selectTeam(String strOrganization) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//label[text()='" + strOrganization + "_Admins']/input/../i", 8); + SeleniumUtil.click("xpath", "//label[text()='" + strOrganization + "_Admins']/input/../i", 8); + + SeleniumUtil.waitForElementVisibilityOf("xpath", "//label[text()='" + strOrganization + "_Admins']/input/../i", 8); + SeleniumUtil.click("xpath", "//label[text()='" + strOrganization + "_DEV']/input/../i", 8); + + SeleniumUtil.waitForElementVisibilityOf("xpath", "//label[text()='" + strOrganization + "_Admins']/input/../i", 8); + SeleniumUtil.click("xpath", "//label[text()='" + strOrganization + "_QA']/input/../i", 8); + + SeleniumUtil.waitForElementVisibilityOf("xpath", "//label[text()='" + strOrganization + "_Admins']/input/../i", 8); + SeleniumUtil.click("xpath", "//label[text()='" + strOrganization + "_DevOps']/input/../i", 8); + + + } catch (Exception ex) { + BaseView.takeScreenshot("selectTeam"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + + } + + public static void clickSaveButton() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//button[@class='btn btn-primary btn-mini']", 8); + SeleniumUtil.click("xpath", "//button[@class='btn btn-primary btn-mini']", 8); + } catch (Exception ex) { + BaseView.takeScreenshot("clickSaveButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickEditDesignerButton(String strDesigner) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']/tbody/tr/td[text()='"+strDesigner+"']/../td[5]/div/a[@title='Edit']", 8); + SeleniumUtil.click("xpath", ".//*[@id='envtable']/tbody/tr/td[text()='"+strDesigner+"']/../td[5]/div/a[@title='Edit']", 8); + + } catch (Exception ex) { + BaseView.takeScreenshot("clickEditDesignerButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + + public static void verifyDesignerUserCreation(String strDesignerUser) { + try { + //WebElement wb= SeleniumUtil.getElement("xpath", "//td[text()='" +strDesignerUser+"'][1]", 8, 8); + //logger.info(wb); + //SeleniumUtil.waitForElementVisibilityOf(wb, 8, 8); + SeleniumUtil.waitUntilElementContainsText("xpath", "//td[text()='"+strDesignerUser+"'][1]", strDesignerUser, 0, 10); + logger.info("User is verfified"); + assertTrue (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']/tbody/tr//td[4][text()='"+strDesignerUser+"']/../td[1][text()='Admin']",strDesignerUser,SeleniumUtilities.OBJWAITTIMEOUT)); + + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDesignerUserCreation"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + + + public static void VerifyEmailAddress(String strDesigner, String strEmailAddress) { + try { + //WebElement wb= SeleniumUtil.getElement("xpath", "//td[text()='" +strDesignerUser+"'][1]", 8, 8); + //logger.info(wb); + //SeleniumUtil.waitForElementVisibilityOf(wb, 8, 8); + SeleniumUtil.waitUntilElementContainsText("xpath", "//td[text()='"+strDesigner+"']/../td[text()='"+strEmailAddress+"']", strEmailAddress , 0, 10); + logger.info("Designer user Email Address is verfified"); + + } catch (Exception ex) { + BaseView.takeScreenshot("VerifyEmailAddress"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + + public static void VerifyDesignerRoleInTable(String strDesigner, String strRole) { + try { + //WebElement wb= SeleniumUtil.getElement("xpath", "//td[text()='" +strDesignerUser+"'][1]", 8, 8); + //logger.info(wb); + //SeleniumUtil.waitForElementVisibilityOf(wb, 8, 8); + SeleniumUtil.waitUntilElementContainsText("xpath", "//td[text()='"+strDesigner+"']/../td[text()='"+strRole+"']", strRole , 0, 10); + logger.info("Designer user Email Address is verfified"); + + } catch (Exception ex) { + BaseView.takeScreenshot("VerifyDesignerRoleInTable"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + + public static void VerifyOrganizationInTable(String strDesigner, String strOrganization) { + try { + //WebElement wb= SeleniumUtil.getElement("xpath", "//td[text()='" +strDesignerUser+"'][1]", 8, 8); + //logger.info(wb); + //SeleniumUtil.waitForElementVisibilityOf(wb, 8, 8); + SeleniumUtil.waitUntilElementContainsText("xpath", "//td[text()='"+strDesigner+"']/../td[text()='"+strOrganization+"']", strOrganization , 0, 10); + logger.info("Designer user Email Address is verfified"); + + } catch (Exception ex) { + BaseView.takeScreenshot("VerifyOrganizationInTable"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + + + public static void VerifyLoginNameDisabled() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//input[@disabled]", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.getAttributeValue("xpath", "//input[@disabled]", "disabled", 8); + } catch (Exception ex) { + BaseView.takeScreenshot("VerifyLoginNameDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + + + } + } + + + + public static void clickOnUpdatePasswordCheckbox() + { + try + { + SeleniumUtil.click("id", "chkadduserldap", 8); + + } + catch (Exception ex) { + BaseView.takeScreenshot("clickOnUpdatePasswordCheckbox"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + + + } + } + + + public static void clickOnDeleteButton(String strDesigner) + { + try + { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']/tbody/tr/td[text()='"+strDesigner+"']/../td[5]/div/a[@title='Delete']/i", 8); + SeleniumUtil.click("xpath", ".//*[@id='envtable']/tbody/tr/td[text()='"+strDesigner+"']/../td[5]/div/a[@title='Delete']/i", 8); + + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnDeleteButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + + + } + } + + public static void clickOnOkButton(String strOk) + { + try + { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//button[text()='"+strOk+"']", 8); + SeleniumUtil.click("xpath", "//button[text()='"+strOk+"']", 8); + + } + catch (Exception ex) { + BaseView.takeScreenshot("clickOnOkButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + + + } + } + + + public static void verfiyEmailAddressUpdated(String strEmailAddress) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//td[text()='"+strEmailAddress+"']", 8); + SeleniumUtil.waitUntilElementContainsText("xpath", "//td[text()='"+strEmailAddress+"']", strEmailAddress , 0, 10); + + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDesignerUserCreation"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + + + public static void selectDefaultTeam(String strDefaultTeam) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//label[text()='"+strDefaultTeam+"']/input/../i", 8); + SeleniumUtil.click("xpath", "//label[text()='"+strDefaultTeam+"']/input/../i", 8); + + } catch (Exception ex) { + BaseView.takeScreenshot("selectTeam"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + + public static void verifyButtonIsEnabled(String org, String edit) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//td[text()='"+org+"']/following-sibling::td//*[@title='"+edit+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb=SeleniumUtil.getElement("xpath",".//*[@id='envtable']//td[text()='"+org+"']/following-sibling::td//*[@title='"+edit+"']",SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.assertNotNull(wb));{ + logger.info(edit +" is Enabled"); +// } else { +// logger.info(edit +" is disbled"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyButtonIsEnabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } } + + public static void verifyDeletedUser(String strDesigner) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+strDesigner+"']/following-sibling::td[2]",1, SeleniumUtilities.OBJWAITTIMEOUT); + if (SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='"+strDesigner+"']")) { + logger.info("This User exists : Not deleted"); + } else { + logger.info("This User does not exists : Org deleted"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDeletedUser"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + +} + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelDockerViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelDockerViews.java new file mode 100755 index 000000000..ac8cb3013 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelDockerViews.java @@ -0,0 +1,206 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 01-08-2016. + */ +public class CreateEditDelDockerViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + public static void clickOnDevopsSetup(String linkText) { + try { + //SeleniumUtil.waitForElementIsClickable("linktext",,8, SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(2000); + SeleniumUtil.click("xpath","//a[text()='"+linkText+"']",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(2000); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnDevopsSetup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + + public static void clickonChefServer(String linkText) { + try { + //SeleniumUtil.waitForElementIsClickable("linktext",,8, SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(2000); + SeleniumUtil.click("xpath","//a[text()='"+linkText+"']",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(2000); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickonChefServer"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + +// public static void clickOnDockerLink(String linktext) { +// try { +// SeleniumUtil.waitForElementIsClickable("linktext",linktext,8, SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("linktext",linktext,SeleniumUtilities.OBJWAITTIMEOUT); +// } +// catch(Exception ex){ +// BaseView.takeScreenshot("clickOnDockerLink"); +// SeleniumUtil.Log.info("Error :" + ex.getMessage()); +// fail(ex.getMessage()); +// } +// } + + public static void enterDockerName(String dockerName) { + try { + SeleniumUtil.waitForElementIsClickable("id","dockerreponame",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","dockerreponame",dockerName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterDockeName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterDockerHubRegistry(String dockerName, String dockerreponame) { + try { + SeleniumUtil.waitForElementIsClickable("id",dockerreponame,8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id",dockerreponame,dockerName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterDockerHubRegistry"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterUserID(String userId) { + try { + SeleniumUtil.waitForElementIsClickable("id","dockerreponame",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","dockerreponame",userId,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterDockerHubRegistry"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterDockerHubRegistryName(String docerHubRegName) { + try { + SeleniumUtil.waitForElementIsClickable("id","dockerrepopath",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","dockerrepopath",docerHubRegName,SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterDockerHubRegistryName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyDocker(String dockerName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+dockerName+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//*[text()='"+dockerName+"']",dockerName,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info(dockerName+"is available"); +// } else { +// logger.info(dockerName+"is not available"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDockerDetails"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifySelOrgIsDisabled() { + + try { + SeleniumUtil.waitForElementVisibilityOf("id","s2id_orgname",5, SeleniumUtilities.OBJWAITTIMEOUT); +// WebElement wb=SeleniumUtil.getElement("id","s2id_orgname",SeleniumUtilities.OBJWAITTIMEOUT); + String actClassValOfElement=SeleniumUtil.getAttributeValue("id","s2id_orgname","class",SeleniumUtilities.OBJWAITTIMEOUT); + String expClassValWhenEleIsDisabled="select2-container select2-container-disabled chooseOrganization width-100"; + assertTrue(actClassValOfElement.equals(expClassValWhenEleIsDisabled));{ + System.out.print(actClassValOfElement); + logger.info("Select organization type is disabled"); +// } else { +// logger.info("Select organization type is enabled"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifySelectOrgIsDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } } + + public static void verifyDockerInfo(String dockerName, String dockerDetails) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+dockerName+"']/../*[text()='"+dockerDetails+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//*[text()='"+dockerName+"']/../*[text()='"+dockerDetails+"']",dockerDetails,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info(dockerName+" with "+dockerDetails+" is available"); +// } else { +// logger.info(dockerName+" with "+dockerDetails+" is available"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDockerDetails"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickTemplateLink(String linkText) { + try { + //SeleniumUtil.waitForElementIsClickable("linktext",,8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//a[text()='"+linkText+"']",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(2000); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickonGallerySetup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickGallerySetuplink(String linkText) { + try { + //SeleniumUtil.waitForElementIsClickable("linktext",,8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//a[text()='"+linkText+"']",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(2000); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickonGallerySetup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void addCookbooksRunlist(String strCookbooks) { + try { + //SeleniumUtil.waitForElementIsClickable("linktext",,8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id", "textbox","apache2", 10); + SeleniumUtil.click("xpath",".//*[@id='cookbooksrecipesList']/option[text()='"+strCookbooks+"']",10); + SeleniumUtil.click("id","btnaddToRunlist",10); + + Thread.sleep(2000); + } + catch(Exception ex){ + BaseView.takeScreenshot("AddCookbooks"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelEnvViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelEnvViews.java new file mode 100755 index 000000000..970c683d6 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelEnvViews.java @@ -0,0 +1,330 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.PageFactory; + +import java.util.Random; +import java.util.logging.Logger; + +import static junit.framework.Assert.assertFalse; +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 26-07-2016. + */ +public class CreateEditDelEnvViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + public static WebElement PagesFrame; + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + public static String envName = ""; + + public static void clickOnEnvironmentsLink() { + try { + SeleniumUtil.waitForElementIsClickable("linktext", "Environments", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext", "Environments", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnEnvironmentsLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickOnChefServerSelButton(String serverName) { + try { + SeleniumUtil.waitForElementIsClickable("xpath", ".//*[@id='s2id_environmentname']/a//b", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", ".//*[@id='s2id_environmentname']/a//b", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("xpath", ".//*[@id='select2-drop']//input", serverName, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.hitEnterKey("xpath", "//span[text()='" + serverName + "']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnChefServerSelButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void enterChefEnvName(String chefEnvName) { + try { + SeleniumUtil.waitForElementIsClickable("id", "chefenvname", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id", "chefenvname", chefEnvName, SeleniumUtil.OBJWAITTIMEOUT); + + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnAddChefEnvButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnAddChefEnvButtonOnEnvPage() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath","(//a[text()='Add'])[1]",5, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "(//a[text()='Add'])[1]", SeleniumUtil.OBJWAITTIMEOUT); + + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnAddChefEnvButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void checkElementIsDisabled(String idOfElement) { + try { + SeleniumUtil.waitForElementIsClickable("id", idOfElement, 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtilities.assertNull(SeleniumUtil.getElement("id", idOfElement, 5, SeleniumUtilities.OBJWAITTIMEOUT)); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnAddChefEnvButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static String enterRandomEnvName(String idOfEditBox) { + try { + int max = 100000; + int min = 10000; + Random r = new Random(); + int ranNumber = r.nextInt((max - min) + 1) + min; + envName = "QA" + ranNumber; + SeleniumUtil.type("id", idOfEditBox,envName, SeleniumUtil.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnAddChefEnvButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + return envName; + } + + public static void verifyEnvName() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+envName+"']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+envName+"']",envName, SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified created environment:" + envName); +// } else { +// logger.info("environment not found:" + envName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEnvName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void verifyAssignedOrgName(String arg0, String org) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//td[text()='" + envName + "']/../td[text()='" + org + "']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//td[text()='" + envName + "']/../td[text()='" + org + "']", org, SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified " + org + " assigned to " + envName); +// } else { +// logger.info("assigned org to environment not found:" + org); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyAssignedOrgNametoEnv"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyEditIsEnabled(String s, String edit) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//td[text()='" + envName + "']/following-sibling::td//*[@title='" + edit + "']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb = SeleniumUtil.getElement("xpath", ".//*[@id='envtable']//td[text()='" + envName + "']/following-sibling::td//*[@title='" + edit + "']", SeleniumUtilities.OBJWAITTIMEOUT); + if (wb.isEnabled()) { + logger.info(edit + " is Enabled"); + } else { + logger.info(edit + " is disbled"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEditIsEnabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifySelectChefServerisDisabled() { + try { +// SeleniumUtil.waitForElementVisibilityOf("id", "s2id_configname", 5, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb = SeleniumUtil.getElement("id", "s2id_configname", SeleniumUtilities.OBJWAITTIMEOUT); + String actClassValOfElement = wb.getAttribute("class"); + String expClassValWhenEleIsDisabled = "select2-container select2-container-disabled chooseOrganization width-100"; + assertTrue (actClassValOfElement.equals(expClassValWhenEleIsDisabled)); + logger.info("Select chef server is disbled"); +// } else { +// logger.info("Select chef server is enabled"); + } catch (Exception ex) { + BaseView.takeScreenshot("verifySelectChefServerisDisabled"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyEnvIsDeleted() { + try { +// SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='" + envName + "']/following-sibling::td[2]", 1, SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='" + envName + "']")); { + logger.info(envName + "Environment does not exists : Deleted"); +// } else { +// logger.info(envName + "Chef server does not exists : deleted"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEnvIsDeleted"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectExistingEnv(String cheEnvName) { + try { +// SeleniumUtil.waitForElementIsClickable("xpath", "//*[@id='s2id_environmentname']/a", 8, SeleniumUtilities.OBJWAITTIMEOUT); +// Thread.sleep(2000); +// SeleniumUtil.click("xpath", "//*[@id='s2id_environmentname']/a", SeleniumUtil.OBJWAITTIMEOUT); +// Thread.sleep(2000); +// SeleniumUtil.waitForElementIsClickable("xpath", "//*[text()='" + cheEnvName + "']", 8, SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("xpath", "//*[text()='" + cheEnvName + "']", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.selectByVisibleText("id","environmentname",cheEnvName,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectExistingEnv"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void verifyEnvInWorkZone() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//span[text()='" + envName + "']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + if (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='" + envName + "']", envName, SeleniumUtilities.OBJWAITTIMEOUT)) { + logger.info("Verified created environment:" + envName); + } else { + logger.info("environment not found:" + envName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEnvName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickOnEnv() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//span[text()='" + envName + "']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "//span[contains(text(),'QA')]", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnEnv"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyAndSelectCreatedEnv() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//span[text()='"+envName+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); +// assertTrue(SeleniumUtil.verifyTextValue("xpath", "//span[text()='"+envName+"']",envName,SeleniumUtilities.OBJWAITTIMEOUT)); { + SeleniumUtil.click("xpath", "//span[text()='"+envName+"']",SeleniumUtilities.OBJWAITTIMEOUT); + logger.info("Verified created environment:" + envName); +// } else { +// logger.info("environment not found:" + envName); + + } catch (Exception ex) { + BaseView.takeScreenshot("verifyAndSelectCreatedEnv"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void assigntheProject(String projectName) + { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='projectname']/label/input[@value='"+projectName+"']/../i",5, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath",".//*[@id='projectname']/label/input[@value='"+projectName+"']/../i",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("assignporject"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void verifySelectedEnvNameFromChef(String environmentName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+environmentName+"']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+environmentName+"']",environmentName, SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified created environment:" + envName); +// } else { +// logger.info("environment not found:" + envName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEnvName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyAssignedDetailsOfEnv(String environmentName, String org) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath",".//*[@id='envtable']//td[text()='"+environmentName +"']/../td[text()='"+org+"']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//td[text()='"+environmentName+"']/../td[text()='"+org+"']",org,SeleniumUtilities.OBJWAITTIMEOUT)); + logger.info("Verified " +org+ "with" +environmentName); +// } else { +// logger.info("environment not found:" + envName); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEnvName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyEditPageIsDisplayed(String pageName) { + try { + assertTrue (SeleniumUtil.verifyTextValue("xpath","//*[text()='"+pageName+"']",pageName,SeleniumUtilities.OBJWAITTIMEOUT)); + logger.info("Verified "+pageName); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEnvName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnAddButton() { + try { + SeleniumUtil.click("cssselector",".btn.btn-default.btn-primary.createchefenvbtn",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnAddButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectNewlyAddedEnv() { + try { + SeleniumUtil.selectByVisibleText("id","environmentname",envName,SeleniumUtil.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectNewlyAddedEnv"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + + } + + public static void verifyEnvironmentIsDeleted(String environmentName) { + try { + assertFalse(SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='" + environmentName + "']")); + logger.info(envName + "Environment does not exists : Deleted"); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEnvIsDeleted"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } +} + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelJenkinsViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelJenkinsViews.java new file mode 100755 index 000000000..56e8cfec5 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelJenkinsViews.java @@ -0,0 +1,66 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 01-08-2016. + */ +public class CreateEditDelJenkinsViews { + + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + public static WebElement PagesFrame; + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + public static void enterJenkinsName(String name,String idOfEditBox){ + try { + SeleniumUtil.waitForElementVisibilityOf("id",idOfEditBox,8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id",idOfEditBox,name,SeleniumUtilities.OBJWAITTIMEOUT); + logger.info("Value entered "+name); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterJenkinsName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyJenkins(String jenkinsPara) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+jenkinsPara+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//*[text()='"+jenkinsPara+"']",jenkinsPara,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified : "+jenkinsPara); +// } else { +// logger.info("Not verified:" +jenkinsPara); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyJenkinsDetails"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + public static void verifyJenkinsDetails(String jenkinsRefName,String jenkinsPara) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//td[text()='"+jenkinsRefName+"']/../*[text()='"+jenkinsPara+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath",".//*[@id='envtable']//td[text()='"+jenkinsRefName+"']/../*[text()='"+jenkinsPara+"']",jenkinsPara,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info(jenkinsRefName+" with "+jenkinsPara+" is available"); +// } else { +// logger.info(jenkinsRefName+" with "+jenkinsPara+" is not available"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyJenkinsDetails"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + +} + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelOrgViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelOrgViews.java new file mode 100755 index 000000000..a953742f8 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelOrgViews.java @@ -0,0 +1,309 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 18-07-2016. + */ +public class CreateEditDelOrgViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + + public static void clickOnSettings() throws InterruptedException { + try { + SeleniumUtil.waitForElementIsClickable("linktext", "SETTINGS", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext", "SETTINGS", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("settingsNew"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickOnOrganizations() { + try { + SeleniumUtil.waitForElementIsClickable("linktext", "ORGANIZATIONS", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext", "ORGANIZATIONS", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("ORGANIZATIONS"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnNewButton(String newButtonId) { + try { + SeleniumUtil.waitForElementIsClickable("id", newButtonId, 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id", newButtonId, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("newOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void saveOrg() { + try { + SeleniumUtil.click("cssselector", "button[class='btn btn-primary btn-mini']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("saveOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void editOrg(String Organization) throws InterruptedException { + try { + SeleniumUtil.waitForElementIsClickable("xpath", ".//*[@id='envtable']/tbody/tr/td[text()='" + Organization + "']/../td[4]//a[@title='Edit']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", ".//*[@id='envtable']/tbody/tr/td[text()='" + Organization + "']/../td[4]//a[@title='Edit']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("editOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clearTheField(String idOfEditbox) { + try { + SeleniumUtil.waitForElementIsClickable("id", idOfEditbox, 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.clear("id", idOfEditbox, SeleniumUtilities.OBJWAITTIMEOUT); + logger.info("Field cleared :" + idOfEditbox); + + } catch (Exception ex) { + BaseView.takeScreenshot("clearTheField"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterNewOrgName(String New_Organization) { + try { + SeleniumUtil.waitForElementIsClickable("id", "orgname", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.clear("id", "orgname", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id", "orgname", New_Organization, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("editOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void delOrg(String New_Organization) { + try { + SeleniumUtil.waitForElementIsClickable("xpath", ".//*[@id='envtable']/tbody/tr/td[text()='" + New_Organization + "']/../td[4]/div/button", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", ".//*[@id='envtable']/tbody/tr/td[text()='" + New_Organization + "']/../td[4]/div/button", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("delOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnOK() { + try { + SeleniumUtil.waitForElementIsClickable("xpath", "//button[text()='OK']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "//button[text()='OK']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnOK"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnSettingsFromOrgPage() { + try { + SeleniumUtil.waitForElementIsClickable("id", "settingsNew", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id", "settingsNew", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnOK"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void seeWorkzone(String idOfElement) { + try { + SeleniumUtil.waitForElementIsClickable("id", idOfElement, 8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("id", idOfElement, "WORKZONE", SeleniumUtilities.OBJWAITTIMEOUT)); + { + SeleniumUtil.Log.info("Workzone is displayed"); +// } else { +// SeleniumUtil.Log.info("Workzone is not displayed"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("seeWorkzone"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void verifyEditedOrg(String editedOrg) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='" + editedOrg + "']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.waitUntilElementContainsText("xpath", ".//*[@id='envtable']//*[text()='" + editedOrg + "']", editedOrg, 5, SeleniumUtilities.OBJWAITTIMEOUT)); + { + logger.info("Verified edited Organization :" + editedOrg); +// } else { +// logger.info("Edited Organization" + editedOrg + " does not exist"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEditedOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyLoginPage() { + try { + SeleniumUtil.waitForElementVisibilityOf("id", "login-form", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitUntilElementContainsText("id", "login-form", "Login", 0, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("id", "login-form", "Login", SeleniumUtilities.OBJWAITTIMEOUT)); + { + logger.info("Verified : LoginPage"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyLoginPage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyStatusOfOrg(String status, String orgName) { + try { + Thread.sleep(2000); + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//td[text()='" + orgName + "']/../td[text()='" + status + "']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//td[text()='" + orgName + "']/../td[text()='" + status + "']", status, 5)); + logger.info("Verified : staus is Active"); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyStatusOfOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void verifyDeletedOrg(String orgName) { + try { +// SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+orgName+"']/following-sibling::td[2]",1, SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='" + orgName + "']")); + logger.info("Organization does not exists :deleted"); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDeletedOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyCreatedOrg(String organizationName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='" + organizationName + "']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='" + organizationName + "']", organizationName, SeleniumUtilities.OBJWAITTIMEOUT)); + logger.info("Verified created organization:" + organizationName); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyCreatedOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyDomainName(String domainName, String orgName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//td[text()='" + orgName + "']/../td[text()='" + domainName + "']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//td[text()='" + orgName + "']/../td[text()='" + domainName + "']", domainName, SeleniumUtilities.OBJWAITTIMEOUT)); + { + logger.info("Verified Domain Name:" + domainName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDomainName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnStatusButton() { + try { + SeleniumUtil.click("xpath", ".//*[@name='checkbox-toggle']/following-sibling::i", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnStatusButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectAllInShowDropDown(String expectedValFromDropdown) { + try { + SeleniumUtil.selectByVisibleText("id", "filteractive", expectedValFromDropdown, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectAllInShowDropDown"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnOkOnAlertPopUp() { + try { + SeleniumUtil.handleParticularAlert("You have selected to change the status of this organization. Proceed?"); + } catch (Exception ex) { + BaseView.takeScreenshot("selectAllInShowDropDown"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnCloseToast() { + try { + SeleniumUtil.click("cssselector", ".toast-close-button", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnCloseToast"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void moveCursorOnMenu() { + try { + Thread.sleep(2000); + SeleniumUtil.mouseOver("xpath", "//strong[text()='Menu']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("moveCursorOnMenu"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void checkAndDecide() { + try { + Thread.sleep(2000); + boolean value = SeleniumUtil.waitForElementVisibilityOf("xpath", "//span[text()='Instances']", 2, SeleniumUtilities.OBJWAITTIMEOUT); + if (value == true){ + System.out.println("Instances Element is visible"); + logger.info("Instances Element is visible"); + SeleniumUtil.click("xpath", ".//*[@id='settings']/a", 8); + + } + else { + logger.info("Instances Element is NOT visible Its In the Settings Page"); + System.out.println("Its In the Settings Page"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("moveCursorOnMenu"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } +} + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelProjectViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelProjectViews.java new file mode 100755 index 000000000..2d7a146c7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDelProjectViews.java @@ -0,0 +1,142 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 20-07-2016. + */ +public class CreateEditDelProjectViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + public static void clickOnProLink() { + try { + SeleniumUtil.waitForElementIsClickable("linktext","Projects",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext","Projects", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnProLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + public static void clickOnNewProButton() { + try { + SeleniumUtil.waitForElementIsClickable("id","newProj",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id","newProj", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnNewProButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnOrg(String proOrg) { + try { + SeleniumUtil.waitForElementIsClickable("xpath",".//*[@id='select2-drop']//div[text()='"+proOrg+"']",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath",".//*[@id='select2-drop']//div[text()='"+proOrg+"']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnOrg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clearProNameField() { + try { + SeleniumUtil.waitForElementIsClickable("id","projectname",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.clear("id","projectname",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clearProNameField"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void typeNewProj(String newProName) { + try { + SeleniumUtil.waitForElementIsClickable("id","projectname",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id","projectname",newProName,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("typeNewProj"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void delProject(String proName) { + try { + SeleniumUtil.waitForElementIsClickable("xpath",".//*[@id='envtable']/tbody/tr/td[text()='"+proName+"']/../td/div/button[@title='Delete']",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath",".//*[@id='envtable']/tbody/tr/td[text()='"+proName+"']/../td/div/button[@title='Delete']",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("typeNewProj"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyCreatedProject(String proName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+proName+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+proName+"']",proName,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified created Project:"+proName); +// } else { +// logger.info("Project not found:" +proName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyCreatedProject"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyDeletedPro(String proName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+proName+"']", 1, SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse (SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='"+proName+"']")); { + logger.info("Project does not exists :deleted"); +// } else { +// logger.info("Project does not exists :"+proName+"deleted"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDeletedProject"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnEnv() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@data-swchon-text='YES']",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath",".//*[@data-swchon-text='YES']",SeleniumUtilities.OBJWAITTIMEOUT); + logger.info("Clicked on environment"); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDeletedProject"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyProjectInfo(String projectName, String projectDetails) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//td[text()='"+projectName+"']/../td[text()='"+projectDetails+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//td[text()='"+projectName+"']/../td[text()='"+projectDetails+"']",projectDetails,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified Project with:"+projectDetails); +// } else { +// logger.info("Project not found:" +assignedOrg); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyProjectInfo"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } +} \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDeleteTeamViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDeleteTeamViews.java new file mode 100755 index 000000000..4d77c83f7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/CreateEditDeleteTeamViews.java @@ -0,0 +1,127 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 16-08-2016. + */ +public class CreateEditDeleteTeamViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + public static void verifyTeamName(String teamName) { + try { + while(true) { + if (SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='" + teamName + "']")) { + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='" + teamName + "']", teamName, SeleniumUtilities.OBJWAITTIMEOUT)); + logger.info("Verified created Team:" + teamName); + break; + } + if(SeleniumUtil.getAttributeValue("id","envtable_next","class",SeleniumUtilities.OBJWAITTIMEOUT).equals("paginate_button next disabled")){ + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='" + teamName + "']", teamName, SeleniumUtilities.OBJWAITTIMEOUT)); + break; + } + else { + SeleniumUtil.click("id", "envtable_next", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitForElementVisibilityOf("id", "newTeam", SeleniumUtilities.OBJWAITTIMEOUT); + } + } + + } catch (Exception ex) { + BaseView.takeScreenshot("verifyTeamName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyTeamDetails(String teamName, String teamDetails) { + try { + while(true) { + if (SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//td[text()='" + teamName + "']/../td[text()='" + teamDetails + "']")) { + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//td[text()='" + teamName + "']/../td[text()='" + teamDetails + "']", teamDetails, SeleniumUtilities.OBJWAITTIMEOUT)); + logger.info("Verified created Team:" + teamName + "with " + teamDetails); + break; + } + if(SeleniumUtil.getAttributeValue("id","envtable_next","class",SeleniumUtilities.OBJWAITTIMEOUT).equals("paginate_button next disabled")){ + break; + } + else { + SeleniumUtil.click("id", "envtable_next", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitForElementVisibilityOf("id", "newTeam", SeleniumUtilities.OBJWAITTIMEOUT); + } + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyTEamDetails"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void checkTheCheckBox(String value) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath","//input[@value='"+value+"']/following-sibling::i",5, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//input[@value='"+value+"']/following-sibling::i",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("checkTheCheckBox"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void searchAndEditTheTeam(String teamName, String edit) { + try { + while(true) { + if (SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='" + teamName + "']")) { + SeleniumUtil.click("xpath",".//*[@id='envtable']//td[text()='"+teamName+"']/following-sibling::td//*[@title='"+edit+"']",SeleniumUtilities.OBJWAITTIMEOUT); + logger.info("Verified created Team:" + teamName); + break; + } + if(SeleniumUtil.getAttributeValue("id","envtable_next","class",SeleniumUtilities.OBJWAITTIMEOUT).equals("paginate_button next disabled")){ + break; + } + else { + SeleniumUtil.click("id", "envtable_next", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitForElementVisibilityOf("id", "newTeam", SeleniumUtilities.OBJWAITTIMEOUT); + } + } + + } catch (Exception ex) { + BaseView.takeScreenshot("verifyTeamName"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyTeamIsDeleted(String teamName) { + try { + SeleniumUtil.click("id","envtable_first",SeleniumUtilities.OBJWAITTIMEOUT); + while(true) { + assertFalse(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+teamName+"']", teamName, SeleniumUtilities.OBJWAITTIMEOUT)); + if(SeleniumUtil.getAttributeValue("id","envtable_next","class",SeleniumUtilities.OBJWAITTIMEOUT).equals("paginate_button next disabled")){ + logger.info("Verified Team is deleted : " + teamName); + break; + } + else { + SeleniumUtil.click("id", "envtable_next", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitForElementVisibilityOf("id", "newTeam", SeleniumUtilities.OBJWAITTIMEOUT); + } + } + + } catch (Exception ex) { + BaseView.takeScreenshot("verifyTeamIsDeleted"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ImportNodesFromChefViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ImportNodesFromChefViews.java new file mode 100755 index 000000000..2bed7dec7 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/ImportNodesFromChefViews.java @@ -0,0 +1,356 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.PageFactory; + +import java.io.File; +import java.util.logging.Logger; + +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 10-08-2016. + */ +public class ImportNodesFromChefViews { + + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + public static String awsid = ""; + public static String IpAddress=""; + + public static void clickOnAWSProvider() { + try { + SeleniumUtil.waitForElementIsClickable("xpath", ".//*[@id='blueprints']//div[@title='AWS']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", ".//*[@id='blueprints']//div[@title='AWS']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnAWSProvider"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectBlueprintType(String blueprintType) { + try { + Thread.sleep(2000); + SeleniumUtil.waitForElementIsClickable("xpath", "//*[text()='"+blueprintType+"']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "//*[text()='"+blueprintType+"']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectBlueprintType"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnNext() { + try { + SeleniumUtil.waitForElementIsClickable("linktext", "Next", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext", "Next", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnNext"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectTemplate(String tempName) { + try { + SeleniumUtil.waitForElementIsClickable("xpath", ".//*[text()='" + tempName + "']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", ".//*[text()='" + tempName + "']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectTemplate"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void selectValues(String valueToSelect, String idOfSelectBox) { + try { + SeleniumUtil.waitForElementIsClickable("id", idOfSelectBox, 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.selectByVisibleText("id", idOfSelectBox, valueToSelect, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectTemplate"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectRegion(String region) { + try { + SeleniumUtil.waitForElementIsClickable("id", "region", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id", "region", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitForElementIsClickable("xpath", "//*[contains(text(),'" + region + "')]", 8, SeleniumUtilities.OBJWAITTIMEOUT); + WebElement wb = SeleniumUtil.getElement("xpath", "//*[contains(text(),'" + region + "')]", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.sendEnterKeyToElement(wb); + } catch (Exception ex) { + BaseView.takeScreenshot("selectTemplate"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectSecurityGrp() { + try { + SeleniumUtil.waitForElementIsClickable("xpath", "//*[text()='sg-eeff688b | default']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "//*[text()='sg-eeff688b | default']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectSecurityGrp"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyEnvDetails(String envDetails) { + try { + SeleniumUtil.waitForElementIsClickable("xpath", "", 8, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.waitForElementContainText("xpath", "//span[contains(text(),'" + envDetails + "')]", envDetails)); + logger.info(envDetails + " is present"); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyEnvDetails"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnLaunchBlueprint() { + try { + SeleniumUtil.waitForElementIsClickable("xpath", "//span[@title='Launch BluePrint']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", "//span[@title='Launch BluePrint']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnLaunchBlueprint"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnWorkzone() { + try { + SeleniumUtil.waitForElementIsClickable("id","workZoneNew", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id","workZoneNew",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnWorkzone"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnLaunchBlueprintPopUp() { + try { + SeleniumUtil.waitForElementVisibilityOf("id", "blueprintLaunch",8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id","blueprintLaunch",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnWorkzone"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnLaunchOnSelBlueprintPopUp() { + try { + SeleniumUtil.waitForElementIsClickable("cssselector", ".btn.btn-default.btn-primary.launchBlueprintBtn", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("cssselector", ".btn.btn-default.btn-primary.launchBlueprintBtn", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnLaunchOnSelBlueprintPopUp"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void captureIpAddress(String bluePrintName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//div[div[text()='"+bluePrintName+"']]/following-sibling::div/strong", 8, SeleniumUtilities.OBJWAITTIMEOUT); + IpAddress=SeleniumUtil.getElementText("xpath", "//div[div[text()='"+bluePrintName+"']]/following-sibling::div/strong", SeleniumUtilities.OBJWAITTIMEOUT); + System.out.println("Captured IP address "+IpAddress); + } catch (Exception ex) { + BaseView.takeScreenshot("captureIpAddress"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void captureAwsId(String bluePrintName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", "//div[div[text()='" +bluePrintName +"']]/../div[contains(text(),'AWS Id')]", 8, SeleniumUtilities.OBJWAITTIMEOUT); + String capturedText = SeleniumUtil.getElementText("xpath", "//div[div[text()='"+bluePrintName+"']]/../div[contains(text(),'AWS Id')]", SeleniumUtilities.OBJWAITTIMEOUT); + String[] parts = capturedText.split(":"); + String awsTitle = parts[0]; + awsid = parts[1].trim(); + System.out.println("AWS title"+awsTitle); + System.out.println("AWS id "+awsid); + } catch (Exception ex) { + BaseView.takeScreenshot("captureAwsId"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + public static void checkTheCheckBoxOfCorrespondingAWSID() { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath",".//*[@id='nodeListTable_filter']//input", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("xpath",".//*[@id='nodeListTable_filter']//input",awsid,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='nodeListTable']//*[text()='"+awsid+"']/..//*[@type='checkbox']", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath", ".//*[@id='nodeListTable']//*[text()='"+awsid+"']/..//*[@type='checkbox']", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnLaunchOnSelBlueprintPopUp"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnImportNodesButton() { + try { + SeleniumUtil.waitForElementIsClickable("id", "buttonForIP", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id","buttonForIP", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnImportNodesButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectBGroupInImportPopUp(String businessGroup,String idOfDropDown) { + try { + SeleniumUtil.waitForElementVisibilityOf("id", idOfDropDown, 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.selectByVisibleText("id",idOfDropDown,businessGroup,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectBGroupInImportPopUp"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterUserNameInPopup(String userName, String idOfEditBox) { + try { + SeleniumUtil.waitForElementVisibilityOf("id", idOfEditBox, 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.type("id",idOfEditBox,userName,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("enterUserNameInPopup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void importPemFileInPopupWindow() { + try{ + String path = new String(new File(".").getCanonicalPath() + "\\src\\test\\resources\\Upload\\bootstrapncal.pem"); + WebDriver driver=SeleniumUtil.getWebDriver(); + driver.findElement(By.id("importPemfileInput")).sendKeys(path); + } + catch(Exception ex){ + BaseView.takeScreenshot("importPemFileInPopupWindow"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickOnImportButton() { + try{ + SeleniumUtil.click("xpath","//button[text()='Import']",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnImportButtonPopupWindow"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void verifyImportingNodesPopUp() { + try{ + SeleniumUtil.waitForElementVisibilityOf("xpath","//h4[text()='Importing Nodes']",SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath","//h4[text()='Importing Nodes']","Importing Nodes",SeleniumUtilities.OBJWAITTIMEOUT)); + logger.info("Importing Nodes is displayed"); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyImportingNodesPopUp"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void clickOnCloseButtonOnPopup() { + try{ + SeleniumUtil.click("cssselector",".btn.btn-default",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickOnCloseButtonOnPopup"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + + } + + public static void verifyNodeImportedMessage() { + try{ + SeleniumUtil.waitForElementPresent("xpath","//div[contains(text(),'Node Imported : "+awsid+"')]"); + SeleniumUtil.verifyTextValue("xpath","//div[contains(text(),'Node Imported : "+awsid+"')]","Node Imported : "+awsid+"",SeleniumUtilities.OBJWAITTIMEOUT); + } + catch(Exception ex){ + BaseView.takeScreenshot("verifyNodeImportedMessage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + } + // public static void browsePemFile() { +// try{ +// //SeleniumUtil.waitForElementIsClickable("xpath","//*[@for='userpemfile']",8, SeleniumUtilities.OBJWAITTIMEOUT); +// //SeleniumUtil.click("xpath","//*[@for='userpemfile']",SeleniumUtilities.OBJWAITTIMEOUT); +// Thread.sleep(5000); +// String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/mycatqa.pem"); +// SeleniumUtil.uploadPemFile(path); +// +// +// //original +// //String path="catalyst\\src\\test\\resources\\Upload"; +// // String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/mycatqa.pem"); +// Thread.sleep(5000); +// } +// catch(Exception ex){ +// BaseView.takeScreenshot("clickOnPemFileBrowse"); +// SeleniumUtil.Log.info("Error :" + ex.getMessage()); +// fail(ex.getMessage()); +// } +// } + public static void selectEnv(String envName) { + try { + SeleniumUtil.selectByVisibleText("id", "chefEnv",envName,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectEnv"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void deleteInstance() { + try { + SeleniumUtil.click("xpath", "//*[@class='card-btns']//button",SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//span[@ng-click='operationSet.deleteInstance(inst, $index);']",SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("cssselector",".btn.cat-btn-delete",SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectEnv"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyConfirmationMsg(String confirmationMsg) { + try { + assertTrue(SeleniumUtil.verifyTextValue("xpath","//*[text()='"+confirmationMsg+"']",confirmationMsg,SeleniumUtilities.OBJWAITTIMEOUT)); + SeleniumUtil.waitUntilElementDisappers("xpath","//*[text()='"+confirmationMsg+"']",3,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("verifyConfirmationMsg"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } +} \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/LoginViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/LoginViews.java new file mode 100755 index 000000000..c76390166 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/LoginViews.java @@ -0,0 +1,234 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.PageFactory; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.fail; + + +/** + * Created by RLE0097 on 21-06-2016. + */ +public class LoginViews { + public static String gmail,yahoo; + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + //Actions act = new Actions(driver); + + public static void enterUsername(String strUserName){ + try { + SeleniumUtil.type("id","Email", strUserName, SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(8000); + WebElement wb=SeleniumUtil.getElement("id","Email",10); + wb.sendKeys(Keys.TAB); + Thread.sleep(3000); + wb.sendKeys(Keys.ENTER); +// SeleniumUtil.findWebElement("name","signIn",10); + Thread.sleep(8000); + System.out.println("I Entered the Gmail Email Address"); + + } + catch(Exception ex){ + BaseView.takeScreenshot("enterUsername"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterYahooUsername(String strUserName){ + try { +// SeleniumUtil.click("xpath","//*[@title='Sign in']",10); + SeleniumUtil.type("id","login-username", strUserName, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id","login-signin",10); + System.out.println("I Entered the Yahoo Email Address"); + + } + catch(Exception ex){ + BaseView.takeScreenshot("enterUsername"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + public static void enterPassword(String strPassword){ + try { + Thread.sleep(8000); + SeleniumUtil.type("id", "Passwd", strPassword, SeleniumUtilities.OBJWAITTIMEOUT); + System.out.println("I Entered the Gmail Password"); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterPassword"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void enterYahooPassword(String strPassword){ + try { + Thread.sleep(1000); + SeleniumUtil.findWebElement(".//*[@id='login-passwd']"); + SeleniumUtil.type("xpath",".//*[@id='login-passwd']", strPassword, SeleniumUtilities.OBJWAITTIMEOUT); + System.out.println("I Entered the Yahoo Password"); + } + catch(Exception ex){ + BaseView.takeScreenshot("enterPassword"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + public static void clickLoginButton(){ + try { + Thread.sleep(4000); + SeleniumUtil.click("xpath", ".//*[@id='signIn']", SeleniumUtilities.OBJWAITTIMEOUT); + System.out.println("I Clicked on Gmail login button"); + Thread.sleep(8000); + //SeleniumUtil.click("css",".T-I.J-J5-Ji.T-I-KE.L3",8); + //SeleniumUtil.waitForElementVisibilityOf("xpath","//*[@title='Starred']",8, 10); + //assertTrue(SeleniumUtil.verifyTextValue("xpath", "//*[@title='Starred']", "Starred" , SeleniumUtilities.OBJWAITTIMEOUT)); + //assertTrue(SeleniumUtil.verifyTextValue("xpath", "//*[@title='Starred']", "Starred" , SeleniumUtilities.OBJWAITTIMEOUT)); + //assertTrue(SeleniumUtil.isElementPresent(By.xpath("//div[text()='COMPOSE']"))); + assertTrue(SeleniumUtil.isElementPresent(By.xpath("//*[@title='Starred']"))); + System.out.println("I am able to see the starred button now"); + } + catch(Exception ex){ + BaseView.takeScreenshot("clickLoginButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void clickYahooLoginButton(){ + try { + SeleniumUtil.click("id", "login-signin", SeleniumUtilities.OBJWAITTIMEOUT); + System.out.println("I Clicked on Yahoo login button"); + Thread.sleep(4000); + //assertTrue(SeleniumUtil.verifyTextValue("xpath", "//b[text()='Home']", "Home" , SeleniumUtilities.OBJWAITTIMEOUT)); + assertTrue(SeleniumUtil.isElementPresent(By.xpath("//*[@id='uh-logo']"))); + System.out.println("I am able to see Home button"); + + } + catch(Exception ex){ + BaseView.takeScreenshot("clickLoginButton"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void signOutGmail(){ + try { + Thread.sleep(4000); + //SeleniumUtil.click("xpath","//div[@class='gb_uc gb_hb gb_yf gb_R']",SeleniumUtilities.OBJWAITTIMEOUT); + //SeleniumUtil.waitForElementIsClickable("xpath","//span[@class='gb_8a gbii']",8,SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("cssselector", "a[title='Sign Out']", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//span[@class='gb_8a gbii']",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(3000); + SeleniumUtil.waitForElementIsClickable("xpath","//a[text()='Sign out']",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//a[text()='Sign out']",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(5000); + assertTrue(SeleniumUtil.isElementPresent(By.xpath("//*[@value='Sign in']"))); + } + + catch(Exception ex){ + BaseView.takeScreenshot("signOut"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void signOutYahoo(){ + try { + Thread.sleep(4000); + SeleniumUtil.click("xpath","//li[@id='uh-profile']",10); + Thread.sleep(2000); + SeleniumUtil.click("xpath","//*[@id='uh-signout']",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(3000); + assertTrue(SeleniumUtil.isElementPresent(By.xpath("//*[@id='uh-signin']"))); + + + //SeleniumUtil.waitForElementIsClickable("xpath","//span[@class='gb_8a gbii']",8,SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("cssselector", "a[title='Sign Out']", SeleniumUtilities.OBJWAITTIMEOUT); + //SeleniumUtil.click("xpath","//span[@class='gb_8a gbii']",SeleniumUtilities.OBJWAITTIMEOUT); + //Thread.sleep(2000); + //SeleniumUtil.waitForElementIsClickable("xpath","//a[text()='Sign out']",8,SeleniumUtilities.OBJWAITTIMEOUT); + //SeleniumUtil.click("xpath","//a[text()='Sign out']",SeleniumUtilities.OBJWAITTIMEOUT); + + } + + catch(Exception ex){ + BaseView.takeScreenshot("signOut"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void signOut(){ + try { + Thread.sleep(2000); + SeleniumUtil.waitForElementIsClickable("id","logout",8,SeleniumUtilities.OBJWAITTIMEOUT); +// SeleniumUtil.click("cssselector", "a[title='Sign Out']", SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("id","logout",SeleniumUtilities.OBJWAITTIMEOUT); + Thread.sleep(2000); + SeleniumUtil.waitForElementIsClickable("xpath","//button[text()=' Yes']",8,SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("xpath","//button[text()=' Yes']",SeleniumUtilities.OBJWAITTIMEOUT); + + } + + catch(Exception ex){ + BaseView.takeScreenshot("signOut"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + + public static void checkURLForApplication() + { + + } + + + public static void whichApplicationToLaunch(String strEmailAppName) + { + try + { + if(strEmailAppName == gmail) + { + System.out.println("Its an Gmail application"); + + + + } + else if (strEmailAppName == yahoo) + { + System.out.println("Its an Yahoo application"); + + } + else + { + System.out.println("Nonoe of the gmail or yahoo application will be opened"); + } + } + catch (Exception e) + { + e.printStackTrace(); + + } + + } + + + public static void loggedout() + { + System.out.println("Logged out of application successfully"); + } + + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/TemplateViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/TemplateViews.java new file mode 100755 index 000000000..22f772032 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/TemplateViews.java @@ -0,0 +1,136 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.LocalFileDetector; +import org.openqa.selenium.remote.RemoteWebElement; +import org.openqa.selenium.support.PageFactory; + +import java.io.File; +import java.util.logging.Logger; + +import static junit.framework.TestCase.*; + +/** + * Created by RLE0372 on 11-08-2016. + */ +public class TemplateViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + public static void clickOnLink(String linkText) { + try { + SeleniumUtil.waitForElementIsClickable("linktext", "Gallery Setup", 8, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.click("linktext", "Gallery Setup", SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("clickOnProLink"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectTempType(String tempType) { + try { + SeleniumUtil.selectByVisibleText("id","templatetypename",tempType,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectTempType"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyTempDetails(String templateName, String tempDetails) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='" + templateName + "']//*[text()='" + tempDetails + "']", 5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='" + templateName + "']/following-sibling::td[text()='" + tempDetails + "']", tempDetails, SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified :" + tempDetails); +// } else { +// logger.info("Not found:" + tempDetails); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyTempDetails"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyDeletedTemp(String tempName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='" + tempName + "']", 1, SeleniumUtilities.OBJWAITTIMEOUT); + assertFalse(SeleniumUtil.isElementExist("xpath", ".//*[@id='envtable']//*[text()='" + tempName + "']")); { + logger.info("Template does not exists :deleted"); +// } else { +// logger.info("Template does not exists : deleted"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDeletedTemp"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyChefFactory(String idOfChkBox) { + try { + SeleniumUtil.waitForElementVisibilityOf("id", idOfChkBox,5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.isElementExist("id", idOfChkBox)); { + logger.info("Chef Factory is displayed"); +// } else { +// logger.info("Chef factory is displayed"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyChefFactory"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyTempName(String tempName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+tempName+"']",4, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+tempName+"']",tempName,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info(tempName + " Created Template is available"); +// } else { +// logger.info(tempName + " Craeted Template is not available"); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyDeletedTemp"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectOrgInTemplatePage(String orgName) { + try { + SeleniumUtil.waitForElementVisibilityOf("id","orgname",1, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.selectByVisibleText("id","orgname",orgName, SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectOrgInTemplatePage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void browseAndUploadTemplateFile(String fileName) { + try { + WebDriver driver=SeleniumUtil.getWebDriver(); + WebElement element = driver.findElement(By.id("template")); + LocalFileDetector detector = new LocalFileDetector(); + String path = new String(new File(".").getCanonicalPath() + "/src/test/resources/Upload/"+fileName); + File f = detector.getLocalFile(path); + ((RemoteWebElement)element).setFileDetector(detector); + element.sendKeys(f.getAbsolutePath()); +// element.sendKeys(path); + } catch (Exception ex) { + BaseView.takeScreenshot("selectOrgInTemplatePage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + +} + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/VMImageViews.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/VMImageViews.java new file mode 100755 index 000000000..7980a9b89 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/java/com/rl/qa/views/VMImageViews.java @@ -0,0 +1,88 @@ +package com.rl.qa.views; + +import com.rl.qa.browsers.BrowserDriver; +import com.rl.qa.steps.LoginSteps; +import com.rl.qa.utils.BaseView; +import com.rl.qa.utils.SeleniumUtilities; +import org.openqa.selenium.support.PageFactory; + +import java.util.logging.Logger; + +import static junit.framework.Assert.assertTrue; +import static junit.framework.TestCase.fail; + +/** + * Created by RLE0372 on 11-08-2016. + */ +public class VMImageViews { + private static final SeleniumUtilities SeleniumUtil = PageFactory.initElements(BrowserDriver.getCurrentDriver(), SeleniumUtilities.class); + private static final Logger logger = Logger.getLogger(LoginSteps.class.getName()); + + + public static void selectOS(String osType) { + try { + SeleniumUtil.selectByVisibleText("id","osType",osType,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectOS"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyCreatedImage(String imageName) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+imageName+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+imageName+"']",imageName,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified created VMImage:"+imageName); +// } else { +// logger.info("VMImage not found:" +imageName); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyCreatedImage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void verifyVMImageDetails(String imageName, String imageDetail) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+imageName+"']/following-sibling::td[text()='"+imageDetail+"']",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue (SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+imageName+"']/following-sibling::td[text()='"+imageDetail+"']",imageDetail,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified VMImage details:"+imageDetail); +// } else { +// logger.info("VMImage details not found:" +imageDetail); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyCreatedImage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + + } + + public static void verifyImageId(String imageName, String imageDetail) { + try { + SeleniumUtil.waitForElementVisibilityOf("xpath", ".//*[@id='envtable']//*[text()='"+imageName+"']/following-sibling::td/span",5, SeleniumUtilities.OBJWAITTIMEOUT); + assertTrue(SeleniumUtil.verifyTextValue("xpath", ".//*[@id='envtable']//*[text()='"+imageName+"']/following-sibling::td/span",imageDetail,SeleniumUtilities.OBJWAITTIMEOUT)); { + logger.info("Verified VMImage details:"+imageDetail); +// } else { +// logger.info("VMImage details not found:" +imageDetail); + } + } catch (Exception ex) { + BaseView.takeScreenshot("verifyCreatedImage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } + + public static void selectOrgInVMImagePage(String orgName) { + try { + SeleniumUtil.waitForElementVisibilityOf("id", "orgId",5, SeleniumUtilities.OBJWAITTIMEOUT); + SeleniumUtil.selectByVisibleText("id","orgId",orgName,SeleniumUtilities.OBJWAITTIMEOUT); + } catch (Exception ex) { + BaseView.takeScreenshot("selectOrgInVMImagePage"); + SeleniumUtil.Log.info("Error :" + ex.getMessage()); + fail(ex.getMessage()); + } + } +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/IEDriverServer.exe b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/IEDriverServer.exe new file mode 100755 index 000000000..ff6e0dcc5 Binary files /dev/null and b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/IEDriverServer.exe differ diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/JSErrorCollector-0.6.jar b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/JSErrorCollector-0.6.jar new file mode 100755 index 000000000..a3b159bd0 Binary files /dev/null and b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/JSErrorCollector-0.6.jar differ diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/chromedriver.exe b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/chromedriver.exe new file mode 100755 index 000000000..c312e1bab Binary files /dev/null and b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/chromedriver.exe differ diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/firebug/firebug-1.9.2.xpi b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/firebug/firebug-1.9.2.xpi new file mode 100755 index 000000000..39294c5f2 Binary files /dev/null and b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/firebug/firebug-1.9.2.xpi differ diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/log4j.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/log4j.properties new file mode 100755 index 000000000..7872524aa --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/log4j.properties @@ -0,0 +1,16 @@ +# Root logger option +log4j.rootLogger=INFO,stdout,file + +# Redirect log messages to console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n + +# Redirect log messages to a log file, support file rolling. +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=${user.dir}\\target\\log4j-application.log +log4j.appender.file.MaxFileSize=5MB +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/lx-selenium.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/lx-selenium.properties new file mode 100755 index 000000000..30383a546 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/lx-selenium.properties @@ -0,0 +1,11 @@ +# The specified maven profile will provide values for the properties below that +# are surrounded by the ${} tokens. + +# IWMS web-ui properties +browser=${browser} +iwms.url=${iwms.url} +iwms.username=${iwms.username} +iwms.password=${iwms.password} +selenium.hub=${selenium.hub} + +iwms.firm=${iwms.firm} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Administrator.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Administrator.properties new file mode 100755 index 000000000..9fd25f1d0 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Administrator.properties @@ -0,0 +1,3 @@ +username=rootDev +firmname=qa2 +password=DES:21GK+y5lCqiLqU3m0cjjejq+YIWfE2Wu diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Broker.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Broker.properties new file mode 100755 index 000000000..232989a71 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Broker.properties @@ -0,0 +1,6 @@ +username=a-broker +firmname=2338 +password=DES:6bshieViClWfoVfxtDwpVQc0kmvGj21N + + + diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Delete.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Delete.properties new file mode 100755 index 000000000..71a259259 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Delete.properties @@ -0,0 +1,3 @@ +username=delUser +firmname=QA2 +password=DES:M/Ac8cUOQcoaz01kiBIEY+YrsGsMQs35 diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Edit.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Edit.properties new file mode 100755 index 000000000..3c580424d --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/Edit.properties @@ -0,0 +1,3 @@ +username=editUser +firmname=QA2 +password=DES:M/Ac8cUOQcoaz01kiBIEY+YrsGsMQs35 \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/NoAccessInAdminDash.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/NoAccessInAdminDash.properties new file mode 100755 index 000000000..51f33c6c4 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/NoAccessInAdminDash.properties @@ -0,0 +1,3 @@ +username=noAccessInAdminDash +firmname=QA2 +password=DES:M/Ac8cUOQcoaz01kiBIEY+YrsGsMQs35 \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/No_Access.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/No_Access.properties new file mode 100755 index 000000000..7e6678be5 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/No_Access.properties @@ -0,0 +1,3 @@ +username=noAccessUser +firmname=QA2 +password=DES:M/Ac8cUOQcoaz01kiBIEY+YrsGsMQs35 \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/View.properties b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/View.properties new file mode 100755 index 000000000..11809657f --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/main/resources/users/View.properties @@ -0,0 +1,3 @@ +username=viewUser +firmname=QA2 +password=DES:M/Ac8cUOQcoaz01kiBIEY+YrsGsMQs35 \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/CreateOrganizationRunner.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/CreateOrganizationRunner.java new file mode 100755 index 000000000..cbe996206 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/CreateOrganizationRunner.java @@ -0,0 +1,22 @@ +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 05-10-2016. + */ + + + +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + "src/test/resources/catalyst/settings/orgsetup/1CreateOrganization.feature", + }, + tags={"@One"}, + glue={"com.rl.qa"}, + format = {"pretty", "html:target/cucumber", "json:target/reports/json/CreateOrganizationRunner.json"} +) + +public class CreateOrganizationRunner { +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/DeleteOrganizationRunner.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/DeleteOrganizationRunner.java new file mode 100755 index 000000000..945284526 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/DeleteOrganizationRunner.java @@ -0,0 +1,20 @@ +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 05-10-2016. + */ + +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + "src/test/resources/catalyst/settings/orgsetup/DeleteOrganization.feature", + }, + tags={"@Delete"}, + glue={"com.rl.qa"}, + format = {"pretty", "html:target/cucumber", "json:target/reports/json/DeleteOrganizationRunner.json"} +) + +public class DeleteOrganizationRunner { +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/Mail.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/Mail.java new file mode 100755 index 000000000..332eb5618 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/Mail.java @@ -0,0 +1,24 @@ + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by rle0346 on 15/11/16. + */ +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + + "src/test/resources/mailApplication/EmailLoginAndLogout.feature" + }, + + tags={"@Application"}, + glue={"com.rl.qa"}, + format = {"pretty", "html:target/cucumber", "json:target/reports/json/Application.json"}) + + + +public class Mail { + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner1.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner1.java new file mode 100755 index 000000000..b19b2ce62 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner1.java @@ -0,0 +1,52 @@ +//package com.rl.qa.steps; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 26-07-2016. + **/ + +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + "src/test/resources/catalyst/settings/orgsetup" + //"src/test/resources/catalyst/settings/orgsetup/CreateOrganization.feature", + //"src/test/resources/catalyst/settings/orgsetup/CreateBusinessGroup.feature", + //"src/test/resources/catalyst/settings/orgsetup/CreateProject.feature", + //"src/test/resources/catalyst/settings/userssetup/CreateSuperadmin.feature", + + + + + // "src/test/resources/catalyst/settings/orgsetup/CreateEditDelOrg.feature", + // "src/test/resources/catalyst/settings/orgsetup/CreateEditDelBGroup.feature", + // "src/test/resources/catalyst/settings/orgsetup/CreateEditDelProject.feature", + // "src/test/resources/catalyst/settings/configsetup/ChefServerSetup.feature", +// "src/test/resources/catalyst/settings/orgsetup/CreateEnvUsingEnvFromChefServer.feature", +// "src/test/resources/catalyst/settings/orgsetup/CreateEditDelEnvByCreatingNewEnv.feature", +// "src/test/resources/catalyst/settings/devopssetup/ConfigureNexusServer.feature", +// "src/test/resources/catalyst/settings/devopssetup/ConfigAWSProviderWithInvalidKey.feature", +// "src/test/resources/catalyst/settings/devopssetup/ConfigureAWSProviderUsingAccessKey.feature", +// "src/test/resources/catalyst/settings/devopssetup/ConfigureAzureProvider.feature", +// "src/test/resources/catalyst/settings/devopssetup/ConfigureOpenStackProvider.feature", +// "src/test/resources/catalyst/settings/devopssetup/ConfigureVMWareProvider.feature", +// "src/test/resources/catalyst/settings/devopssetup/CreateEditDelDocker.feature", +// "src/test/resources/catalyst/settings/devopssetup/CreateEditDelJenkins.feature", +// "src/test/resources/catalyst/settings/userssetup/CreateEditDelDesigner.feature", +// "src/test/resources/catalyst/settings/userssetup/CreateEditDelSuperadmin.feature", +// "src/test/resources/catalyst/settings/userssetup/CreateEditDeleteTeams.feature", +// "src/test/resources/catalyst/settings/userssetup/CreateEditDelOrgAdmin.feature", + }, + + tags={"@One,@Two,@Three"}, + glue={"com.rl.qa"}, + format = {"pretty", "html:target/cucumber", "json:target/reports/json/TestRunner1.json", "junit:target/test-report.xml"}) + + +public class TestRunner1 { + + + +} \ No newline at end of file diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner2.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner2.java new file mode 100755 index 000000000..64888212e --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner2.java @@ -0,0 +1,24 @@ +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 23-08-2016. + */ +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + + "src/test/resources/catalyst/settings/userssetup", + + // "src/test/resources/catalyst/settings/configsetup/CreateEnvUsingEnvFromChefServer.feature", + //"src/test/resources/catalyst/settings/configsetup/CreateEditDelEnvByCreatingNewEnv.feature", + //"src/test/resources/catalyst/settings/userssetup/CreateEditDeleteTeams.feature", + //"src/test/resources/catalyst/settings/userssetup/CreateOrgAndVerifyFourAutoCreatedTeams.feature", + }, + tags={"@Four,@Five"}, + glue={"com.rl.qa"}, + format = {"json:target/reports/json/TestRunner2.json"}) +public class TestRunner2 { + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner3.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner3.java new file mode 100755 index 000000000..95d8fac30 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner3.java @@ -0,0 +1,22 @@ +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 23-08-2016. + */ + @RunWith(Cucumber.class) + @CucumberOptions( + features = { + "src/test/resources/catalyst/settings/configsetup", + //"src/test/resources/catalyst/settings/devopssetup/ConfigureAWSProviderUsingAccessKey.feature", +// "src/test/resources/catalyst/settings/devopssetup/ConfigureAzureProvider.feature", + //"src/test/resources/catalyst/settings/devopssetup/ConfigureOpenStackProvider.feature", + //"src/test/resources/catalyst/settings/devopssetup/ConfigureVMWareProvider.feature", + }, + tags={"@Six,@Seven,@Eight"}, + glue={"com.rl.qa"}, + format = {"json:target/reports/json/TestRunner3.json"}) + public class TestRunner3 { + + } diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner4.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner4.java new file mode 100755 index 000000000..69ce0f138 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner4.java @@ -0,0 +1,25 @@ +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 23-08-2016. + */ +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + + "src/test/resources/catalyst/settings/gallerysetup" + + //"src/test/resources/catalyst/settings/userssetup/CreateEditDelDesigner.feature", + //"src/test/resources/catalyst/settings/userssetup/CreateEditDelSuperadmin.feature", + //"src/test/resources/catalyst/settings/userssetup/CreateEditDelOrgAdmin.feature", + //"src/test/resources/catalyst/settings/devopssetup/ConfigAWSProviderWithInvalidKey.feature", + }, + glue={"com.rl.qa"}, + tags={"@Nine,@Ten"}, + format = {"json:target/reports/json/TestRunner4.json"}) +public class TestRunner4 { + + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner5.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner5.java new file mode 100755 index 000000000..28dfdef92 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner5.java @@ -0,0 +1,24 @@ +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 25-08-2016. + */ + +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + + "src/test/resources/catalyst/settings/devopssetup" + // "src/test/resources/catalyst/settings/gallerysetup/CreateEditDelCloudFormationTemp.feature", + //"src/test/resources/catalyst/settings/gallerysetup/CreateEditDelDockerTemplate.feature", + //"src/test/resources/catalyst/settings/gallerysetup/CreateEditDeleteARMTemplate.feature", + //"src/test/resources/catalyst/settings/gallerysetup/CreateEditDelSoftwareStackTemp.feature" + }, + glue={"com.rl.qa"}, + tags={"@Eleven,@Twelve"}, + format = {"json:target/reports/json/TestRunner5.json"}) +public class TestRunner5 { + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner6.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner6.java new file mode 100755 index 000000000..ec9b5d413 --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner6.java @@ -0,0 +1,21 @@ +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 29-08-2016. + */ + +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + "src/test/resources/catalyst/settings/gallerysetup/CreateEditDeleteVMImageUsingProviderTypeAzure.feature", + "src/test/resources/catalyst/settings/gallerysetup/CreateEditDelVMImageUsingProviderTypeOpenStack.feature", + "src/test/resources/catalyst/settings/gallerysetup/CreateEditDelVMImageUsingProviderTypeAWS.feature", + "src/test/resources/catalyst/settings/gallerysetup/CreateEditDelVMImageUsingProviderTypeVMware.feature" + }, + glue={"com.rl.qa"}, + format = {"json:target/reports/json/TestRunner6.json"}) +public class TestRunner6 { + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner7.java b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner7.java new file mode 100755 index 000000000..7b90a0eab --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/java/TestRunner7.java @@ -0,0 +1,22 @@ +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +/** + * Created by RLE0372 on 06-09-2016. + */ + +@RunWith(Cucumber.class) +@CucumberOptions( + features = { + "src/test/resources/catalyst/settings/devopssetup/CreateEditDelDocker.feature", + "src/test/resources/catalyst/settings/devopssetup/CreateEditDelJenkins.feature", + "src/test/resources/catalyst/settings/devopssetup/ConfigureNexusServer.feature", +// "src/test/resources/catalyst/settings/devopssetup/ConfigAWSProviderWithInvalidKey.feature", + "src/test/resources/catalyst/settings/devopssetup/ConfigureAzureProvider.feature", + }, + glue={"com.rl.qa"}, + format = {"json:target/reports/json/TestRunner7.json"}) +public class TestRunner7 { + +} diff --git a/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/resources/Design/ConfigBlueprintForCFTUsingProAWS.feature b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/resources/Design/ConfigBlueprintForCFTUsingProAWS.feature new file mode 100755 index 000000000..b2354c16e --- /dev/null +++ b/server/undefined58da62749a03cc310995d810/RLIndia-botsfactory-f9147731953d936b21e1c6bf4fd0d2a85ad55c18/Code/UI_BOTs/Gmail_UserCreation/src/test/resources/Design/ConfigBlueprintForCFTUsingProAWS.feature @@ -0,0 +1,201 @@ +@All +Feature: As a super user I Configure Blueprint for Cloud Formation Template using provider type AWS + Scenario Outline: As a super user I create a organization + Given I Login to catalyst using "" access credentials + And I see the catalyst "workzone" + And I click on "SETTINGS" link + And I click on Organizations link in main page + And I click on "newOrg" button + And I enter "" in "orgname" Edit box + And I click on save button + And I verify the created "" in list + + Examples: + | Login User | Organization | + | superadmin | UAT_RL1 | + + Scenario Outline: As a super user I create a Business group + And I click on Business Groups Link + And I click on New BGroup button + And I enter the "" name in Business Group name + And I select "" from the select box + And I click on save button + And I verify the created "" in Business group table + + Examples: + | Business Group | Organization | + | Cat_UAT | UAT_RL1 | + + Scenario Outline: As a super user I create a Project + And I click on Projects link + And I click on "newProj" button + And I enter "" in "projectname" Edit box + And I enter "" in "description" Edit box + And I select "" from the select box + And I click on save button + And I verify the created "" in project table + Examples: + |Project name|Organization |Description | + | Catalyst |UAT_RL1 | Catalyst_UAT_RL| + + Scenario Outline: As a super user I create a chef server + And I click on "Config Setup" link + And I click on "Chef Server" link + And I click on "newConfig" button + And I enter "" in "configname" Edit box + And I enter "" in "loginname" Edit box + And I enter "" in "url" Edit box + And I select "" from the select box + And I click on user pem file browse button + And I click on knife file browse button +# And I upload pem file "" +# And I upload knife file "" + And I click on save button + And I verify created "" in chef server table + + Examples: + | Chef Server | User Name | URL | Organization | + | Cat_Chef_Server | mycatqa |https://api.opscode.com/organizations/cattest | UAT_RL1 | + + Scenario Outline: As a super user I create environment + And I click on Environments link + And I click on "newENV" button + And I select "" from the select box + And I select "" from the select box + And I select existing chef "" from chef server + And I check the "" check box +# And I check the "" check box + And I click on save button + And I verify created "" in environments table + + Examples: + | Organization |environment |Organization_1|Project | + | UAT_RL1 |QA957 |Smoke_Rel_Org |Catalyst| + + Scenario Outline: As a super user I create a Team + And I click on the "Users Setup" link + And I click on the "Teams" link + And I click on "newTeam" button + And I enter "" in "teamname" Edit box + And I enter "" in "description" Edit box + And I select "" from the select box + And I check the "superadmin" check box + And I check the "" check box +# And I check the "" check box + And I click on save button + And I verify created "" in the teams table + + Examples: + |Team Name |Description |Organization |Project | + |UatAutoTeam13 |UAT Automation Team| UAT_RL1 |Catalyst | + + Scenario Outline: As a super user I create a AWS Provider + And I click on "DevOps Setup" link + And I click on "Providers" link + And I click on "addnewitem" button + And I select provider type "AWS" + And I enter "" in "name" Edit box + And I click on "credentials-accessKeys" User Access Key + And I enter "" in "accessKey" Edit box + And I enter "" in "secretKey" Edit box + And I enter "" in "s3BucketName" Edit box + And I select "" from the select box in new provider page + And I enter "" in "plannedCost" Edit box + And I select "" from the region select box + And I select "" from the key pair select box + And I click on user pem file browse button and select pem file + And I click on save button + And I verify "" in the provider table + Examples: + |AWS service name |Access Key |Secret Key |S3 Bucket Name|Organization|Region |Key Pair |Planned cost| + |RL_AWS | AKIAIIK5APRNV54QAVQA |bz6Hl4wtjXi5Mg2EaZxLR1I/7y0bmYXEiYINDBSp | RLBilling | UAT_RL1 |US West (N. California)| bootstrapncal|10000| + + Scenario Outline: As a super user I create VMImage + And I click on "Gallery Setup" link + And I click on "VMImage" link + And I click on "addnewitem" button + And I enter "" in "name" Edit box + And I select "" from the select box in VMImage page + And I select "" type + And I enter "" in "imageidentifire" Edit box + And I enter "" in "UserName" Edit box + And I click on save button + And I verify created "" in the Images table + + Examples: + |VMImage Name|Organization|Operating System|Image ID |Admin User Name| + | RL_VM | UAT_RL1 | Ubuntu |ami-06116566|ubuntu | + + Scenario Outline: As a super user I create Cloud Formation Template + And I click on "Templates" link + And I click on "newTemplate" button + And I enter "