NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.standardchartered.s2b.controller;

import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.Platform;
import org.openqa.selenium.Point;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ThreadGuard;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.internal.Nullable;

import com.google.common.base.Predicate;
import com.standardchartered.s2b.excelAPI.ExcelOperation;
import com.standardchartered.s2b.pages.AdhocPayee;
import com.standardchartered.s2b.pages.AdhocPayeePage;
import com.standardchartered.s2b.pages.ApprovePaymentsPage;
import com.standardchartered.s2b.pages.AuditTrailPage;
import com.standardchartered.s2b.pages.BookFXPage;
import com.standardchartered.s2b.pages.ConfirmationPage;
import com.standardchartered.s2b.pages.CreatePayeePage;
import com.standardchartered.s2b.pages.CreatePaymentPage;
import com.standardchartered.s2b.pages.DashboardPage;
import com.standardchartered.s2b.pages.DeletePayeeSecondaryVerifyDeletedPayeePage;
import com.standardchartered.s2b.pages.EditPayeePage;
import com.standardchartered.s2b.pages.ExportPayeePage;
import com.standardchartered.s2b.pages.ForexAuthorisationDeclarationPage;
import com.standardchartered.s2b.pages.InitiatePaymentPage;
import com.standardchartered.s2b.pages.LinkContractToPaymentPage;
import com.standardchartered.s2b.pages.LoginPage;
import com.standardchartered.s2b.pages.ManageFXPage;
import com.standardchartered.s2b.pages.ManagePage;
import com.standardchartered.s2b.pages.ManagePaymentsPage;
import com.standardchartered.s2b.pages.ManualPaymentSummaryPage;
import com.standardchartered.s2b.pages.MultiSelectApprovalPage;
import com.standardchartered.s2b.pages.PayeeApprovePage;
import com.standardchartered.s2b.pages.PayeeCreateAddUnlistedCodePage;//PayeeSendForRepairSecondary
import com.standardchartered.s2b.pages.PayeeSendForRepairSecondary;
import com.standardchartered.s2b.pages.EditPayeeSecondaryCancelPage;
import com.standardchartered.s2b.pages.ManageCreatePayee;
import com.standardchartered.s2b.pages.PayeeCreateAnotherPage;
import com.standardchartered.s2b.pages.RejectPaymentPage;
import com.standardchartered.s2b.pages.SelectFXContractPage;
import com.standardchartered.s2b.pages.SortPage;
import com.standardchartered.s2b.pages.ViewPayeeAddUnlistedCodePage;
import com.standardchartered.s2b.pages.PayeeCreateErrorValidation;
import com.standardchartered.s2b.testData.TestDataObject_AdhocPayee;
import com.standardchartered.s2b.testData.TestDataObject_Payee;
import com.standardchartered.s2b.testData.TestDataObject_Payments;
import com.standardchartered.s2b.utility.Constant;

public class FlowMethods {

// List<List<String>> LIST_FOR_DEPEDENCY = Collections
// .synchronizedList(new ArrayList<List<String>>());//
// AtomicInteger counter = new AtomicInteger();

private FileInputStream stream;
public Properties ObjectRepo = new Properties();

// private WebDriver driver;
private WebDriver payeeDriver;
private WebDriver paymentsDriver;
String FX_reference="";

private final ConcurrentHashMap<String, List<String>> DEPENDENCY_VALUES = new ConcurrentHashMap<String, List<String>> ();
private final AtomicBoolean matchingResult = new AtomicBoolean(true);

/*************************************************************/



// ActionMethods actionMethods = null;
//Commented
// ActionMethods actionMethods = new ActionMethods(driver);

public FlowMethods() throws IOException {
populateObjectRepository();

}

public void populateObjectRepository() throws IOException {

File src = new File("./ObjectRepository.properties");
stream = new FileInputStream(src);
ObjectRepo.load(stream);
System.out.println("Property class loaded");
}

public void Login(String moduleName) throws Exception {

System.out.println(" 08. Thread -> " + Thread.currentThread().getName() + " | Function - Login | Module Name passed - " + moduleName);

/************ Fetch the instance from WebdriverFactory ***************/
WebDriver driver = WebdriverFactory.getInstance().getDriver();
LoginPage loginPage = new LoginPage();
ActionMethods actionMethods = new ActionMethods();
/**********************************************************************/



String username ="";
String groupdID="";
String twoFAType="";
String twoFAPassword="";

if(moduleName.equalsIgnoreCase("Payee")) {
System.out.println(" 09 " + Thread.currentThread().getName() + " Thread assigning user ID and Group ID in PayeeBlock");
String[] separated = TestDataObject_Payee.PILOT_GROUP.split("/");
username=TestDataObject_Payee.USERNAME = separated[0];
groupdID = TestDataObject_Payee.GROUP_ID = separated[1];
twoFAType=TestDataObject_Payee.TWO_FA_TYPE = separated[2];
twoFAPassword=TestDataObject_Payee.TWO_FA_PASSWORD = separated[3];
}

else if(moduleName.equalsIgnoreCase("Payments")) {
System.out.println(" 09 " + Thread.currentThread().getName() + " Thread assigning user ID and Group ID in Payment Block");

String[] separated = TestDataObject_Payments.PILOT_GROUP.split("/");
username=TestDataObject_Payments.USERNAME = separated[0];
groupdID = TestDataObject_Payments.GROUP_ID = separated[1];
twoFAType=TestDataObject_Payments.TWO_FA_TYPE = separated[2];
twoFAPassword=TestDataObject_Payments.TWO_FA_PASSWORD = separated[3];
}

else if(moduleName.equalsIgnoreCase("Adhoc_Payee")) {
System.out.println(TestDataObject_AdhocPayee.PILOT_GROUP);
String[] separated = TestDataObject_AdhocPayee.PILOT_GROUP.split("/");
System.out.println(separated);
username=TestDataObject_AdhocPayee.USERNAME = separated[0];
groupdID = TestDataObject_AdhocPayee.GROUP_ID = separated[1];
twoFAType=TestDataObject_AdhocPayee.TWO_FA_TYPE = separated[2];
twoFAPassword=TestDataObject_AdhocPayee.TWO_FA_PASSWORD = separated[3];
}

/******************************* USER ID AND GROUP ID VALIDATION FOR DEPENDECNY JOURNEY**********************/

System.out.println(Thread.currentThread().getName() + " is addding USERID and GROUP ID");

//Payee (User1, group 1)
// payment (User 1, group 1)
//Payee (SameUser id or diff user ID)

if(DEPENDENCY_VALUES.get(Thread.currentThread().getName()) !=null )
{
System.out.println("USER ID and GROUP ID requested by Thread-> " + Thread.currentThread().getName() + " exist ");
List<String> EXISTINGUSERID = Collections.synchronizedList(DEPENDENCY_VALUES.get(Thread.currentThread().getName()));//user 1, group 1
DEPENDENCY_VALUES.replace(Thread.currentThread().getName(), DEPENDENCY_VALUES.get(Thread.currentThread().getName()),Arrays.asList(username,groupdID));
Boolean comparison = EXISTINGUSERID.equals(DEPENDENCY_VALUES.get(Thread.currentThread().getName()))? true: false;
matchingResult.set(comparison);



}else
{
System.out.println("User ID and Group ID do not exist");
DEPENDENCY_VALUES.putIfAbsent(Thread.currentThread().getName(), Arrays.asList(username,groupdID));
}


/***********************************************************************************************************/
System.out.println("User ID and GroupID is mismatching, thereby login function is getting executed by " + Thread.currentThread().getName()); //Logger at debug level
//Invoke ActionMethod.Logout_And_LoginAgain function
//Logout_And_LoginAgain(HashMap<String,String> stepDetails, Map<String,String> testData)
/**********************Mention methods that should get executed as a part of LOGIN SCENARIO ****************************/


actionMethods.launchURL();
System.out.println("Checking driver instance" + (driver instanceof WebDriver));
System.out.println("This is the driver in flow method ="+ driver.getWindowHandle());



actionMethods.waitFor();
loginPage.enterusername(username);
actionMethods.waitFor();
loginPage.clickLogin();
actionMethods.waitFor();
loginPage.enterGroupID(groupdID);
loginPage.enter2FAType(twoFAType);
loginPage.enter2FAPassword(twoFAPassword);
loginPage.clickSubmit();
// actionMethods.waitFor();
}
/*************************** END OF USER ID AND GROUP ID VALIDATION ***************************************/
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.