Notes
Notes - notes.io |
{
try
{ //load correct value
String value="";
if(stepDetails.get("Field Name").equalsIgnoreCase("Debit Date")||stepDetails.get("Field Name").equalsIgnoreCase("Invoice Date")||stepDetails.get("Field Name").equalsIgnoreCase("Value Date"))
{
if(testData.get(stepDetails.get("Field Name"))==null)
{
value=null;
}
else
{
value=testData.get(stepDetails.get("Field Name"));
}
}
else
{
if(testData.get("Search Value")==null || testData.get("Search Value").equals("")|| testData.get("Search Value").equalsIgnoreCase("NA") ) {
value=testData.get(stepDetails.get("Field Name"));
}
else
{
value= testData.get("Search Value");
}
}
//Perform date picker if value is not NULL
if(value.equals(null) || value.equals("")|| value.equalsIgnoreCase("NA") )
{
log.info(value+" is not applicable for this transaction (as per the testData)");
}
else
{
System.out.println("In Date picker");
By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
System.out.println("Locator value"+stepDetails.get("Locator Type")+stepDetails.get("Locator Value"));
WebElement element= waitForElementToBeClickable(locator,60);
element.click();
System.out.println("Calender Clicked");
//element.sendKeys(Keys.PAGE_UP);
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_PAGE_UP);
robot.keyRelease(KeyEvent.VK_PAGE_UP);
String Payment_date = value;
System.out.println("Payment_date"+Payment_date);
Date initDate = new SimpleDateFormat("dd/MM/yyyy").parse(Payment_date);
System.out.println("initDate"+initDate);
SimpleDateFormat formatter1 = new SimpleDateFormat("dd-MMM-yyyy");
String parsedDate = formatter1.format(initDate);
System.out.println("Value Date:"+parsedDate);
String input=null;
String inputdate=null;
input = parsedDate.substring(3, 6);
System.out.println("input"+input);
inputdate = parsedDate.substring(0, 2);
System.out.println("inputdate"+inputdate);
String printDate=parsedDate.substring(0,1);
System.out.println("printDate"+printDate);
if(printDate.equals("0"))
{
inputdate=parsedDate.substring(1, 2);
}
waitFor(stepDetails, testData);
System.out.println("Click on Month");
By locator1 = findByLocator(stepDetails.get("SupportingElement_1_LocatorType"),stepDetails.get("SupportingElement_1_LocatorValue"));
WebElement element1= waitForElementToBeClickable(locator1, 30);
element1.click();
By locator2 =findByLocator(stepDetails.get("SupportingElement_2_LocatorType"),stepDetails.get("SupportingElement_2_LocatorValue"));
WebElement element2= waitForElementToBeClickable(locator2, 30);
System.out.println("Waited for element2");
By locator3 = findByLocator(stepDetails.get("SupportingElement_3_LocatorType"),stepDetails.get("SupportingElement_3_LocatorValue"));
System.out.println("Waited for locator3");
List<WebElement> columns = element2.findElements(locator3);
for (WebElement cell : columns) {
System.out.println("cell values :"+cell.getText());
if (cell.getText().equals(input)) {
System.out.println("Cell"+cell.getText());
cell.click();
break;
}
}
By locator4 =findByLocator(stepDetails.get("SupportingElement_4_LocatorType"),stepDetails.get("SupportingElement_4_LocatorValue"));
WebElement element4= waitForElementToBeClickable(locator4, 30);
System.out.println("Waited for element4"+stepDetails.get("SupportingElement_4_LocatorType")+stepDetails.get("SupportingElement_4_LocatorValue"));
By locator5 = findByLocator(stepDetails.get("SupportingElement_5_LocatorType"),stepDetails.get("SupportingElement_5_LocatorValue"));
System.out.println("Waited for element5"+stepDetails.get("SupportingElement_5_LocatorType")+stepDetails.get("SupportingElement_5_LocatorValue"));
System.out.println("Waited for locator5");
List<WebElement> columns1 = element4.findElements(locator5);
System.out.println("List Size"+columns1.size());
System.out.println("input"+inputdate);
for (WebElement cell1 : columns1)
{
//System.out.println("In For Loop");
System.out.println("cell values :"+cell1.getText());
if (cell1.getText().equals(inputdate)) {
System.out.println("Cell"+cell1.getText());
cell1.click();
break;
}
}
/* // SET ZOOM 100%
element.sendKeys(Keys.CONTROL,"0");*/
}
}
catch (Exception e)
{
String message="The specified data in "+stepDetails.get("Field Name")+" is not found OR "+stepDetails.get("Field Name")+" is not loaded completely after sufficient wait time. Please refer "+testData.get("TestCaseName")+".jpg for more details" ;
log.info(message);
log.info(e.getMessage());
DriverScript.bResult="fail";
DriverScript.eMessage=message;
}
}
public void DatePicker2(HashMap<String,String> stepDetails, Map<String,String> testData) throws MyException,Exception
{
try
{ //load correct value
String value="";
if(stepDetails.get("Field Name").equalsIgnoreCase("Debit Date")||stepDetails.get("Field Name").equalsIgnoreCase("Invoice Date")||stepDetails.get("Field Name").equalsIgnoreCase("Value Date"))
{
if(testData.get(stepDetails.get("Field Name"))==null)
{
value=null;
}
else
{
value=testData.get(stepDetails.get("Field Name"));
}
}
//Perform date picker if value is not NULL
if(value.equals(null) || value.equals("")|| value.equalsIgnoreCase("NA") )
{
log.info(value+" is not applicable for this transaction (as per the testData)");
}
else
{
String Payment_date = value;
List<String> Datelist = Arrays.asList(Payment_date.split("/"));
System.out.println("Payment_date"+Payment_date);
for(int i=0;i<Datelist.size();i++)
{
Datelist.get(i);
System.out.println( Datelist.get(i));
}
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = new Date();
System.out.println("Currnet date "+dateFormat.format(date));
String s1=dateFormat.format(date);
System.out.println("s1"+s1);
List<String> Datelist1 = Arrays.asList(s1.split("/"));
System.out.println("Payment_date"+s1);
for(int i=0;i<Datelist1.size();i++)
{
Datelist1.get(i);
System.out.println(Datelist1.get(i));
}
int Yeardiff=diff(Datelist.get(2),Datelist1.get(2));
int monthdiff=diff(Datelist.get(1),Datelist1.get(1));
int clicks=0;
System.out.println("Yeardiff"+Yeardiff+"monthdiff"+monthdiff);
By loca = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
WebElement elem= waitForElementToBeClickable(loca, 30);
elem.click();
if(Yeardiff<0)
{
int Yeardiff1=Math.abs(Yeardiff);
//Click on left arrow
clicks=Yeardiff1*12+Math.abs(monthdiff);
System.out.println("clicks"+clicks);
for(int i=1;i<=clicks;i++)
{
By locator1 = findByLocator(stepDetails.get("SupportingElement_1_LocatorType"),stepDetails.get("SupportingElement_1_LocatorValue"));
WebElement element1= waitForElementToBeClickable(locator1, 30);
element1.click();
}
}
else if(Yeardiff>0)
{
//Click on right arrow
clicks=Yeardiff*12+monthdiff;
System.out.println("clicks"+clicks);
for(int i=1;i<=clicks;i++)
{
By locator1 = findByLocator(stepDetails.get("SupportingElement_2_LocatorType"),stepDetails.get("SupportingElement_2_LocatorValue"));
WebElement element1= waitForElementToBeClickable(locator1, 30);
element1.click();
}
}
else if(monthdiff<0)
{
int monthdiff1=Math.abs(Math.abs(Yeardiff));
clicks=monthdiff1;
for(int i=1;i<=clicks;i++)
{
By locator1 = findByLocator(stepDetails.get("SupportingElement_1_LocatorType"),stepDetails.get("SupportingElement_1_LocatorValue"));
WebElement element1= waitForElementToBeClickable(locator1, 30);
element1.click();
}
}
else if(monthdiff>0)
{
clicks=monthdiff;
for(int i=1;i<=clicks;i++)
{
By locator1 = findByLocator(stepDetails.get("SupportingElement_2_LocatorType"),stepDetails.get("SupportingElement_2_LocatorValue"));
WebElement element1= waitForElementToBeClickable(locator1, 30);
element1.click();
}
}
By locator1 = findByLocator(stepDetails.get("SupportingElement_4_LocatorType"),stepDetails.get("SupportingElement_4_LocatorValue"));
WebElement element1= waitForElementToBeClickable(locator1, 30);
By locator2 = findByLocator(stepDetails.get("SupportingElement_3_LocatorType"),stepDetails.get("SupportingElement_3_LocatorValue"));
List<WebElement> list=element1.findElements(locator2);
for(WebElement temp:list)
{
String valuedate1=Datelist.get(0);
String printDate=valuedate1.substring(0,1);
System.out.println("printDate"+printDate);
if(printDate.equals("0"))
{
valuedate1=valuedate1.substring(1, 2);
}
System.out.println("valuedate1"+valuedate1);
String str=temp.getText();
System.out.println("Date "+str);
if(str.contains(valuedate1))
{
temp.click();
break;
}
}
}
}
catch (Exception e)
{
String message="The specified data in "+stepDetails.get("Field Name")+" is not found OR "+stepDetails.get("Field Name")+" is not loaded completely after sufficient wait time. Please refer "+testData.get("TestCaseName")+".jpg for more details" ;
log.info(message);
log.info(e.getMessage());
DriverScript.bResult="fail";
DriverScript.eMessage=message;
}
}
public static int diff(String str1,String str2)
{
int diffvalue=0;
diffvalue=Integer.parseInt(str1)- Integer.parseInt(str2);
return diffvalue;
}
public void FileUpload(HashMap<String,String> stepDetails, Map<String,String> testData) throws MyException,Exception
{
try
{
String value=testData.get(stepDetails.get("Field Name"));
if(value.equals(null) || value.equals("")|| value.equalsIgnoreCase("NA") ) {
log.info(value+" is not applicable for this transaction (as per the testData)");
}
else
{
By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
waitForElementToBeClickable(locator,30).click();
waitFor(stepDetails, testData);
StringSelection filePath = new StringSelection(value);
System.out.println("Attachement Path:"+value);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(filePath, null);
//native key strokes for CTRL, V and ENTER keys
Robot robot = new Robot();
waitFor(stepDetails, testData);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
}
catch (Exception e)
{
String message="The specified data in "+stepDetails.get("Field Name")+" is not found OR "+stepDetails.get("Field Name")+" is not loaded completely after sufficient wait time. Please refer "+testData.get("TestCaseName")+".jpg for more details" ;
log.info(message);
log.info(e.getMessage());
DriverScript.bResult="fail";
DriverScript.eMessage=message;
}
}
public void keyDown(HashMap<String,String> stepDetails, Map<String,String> testData)throws Throwable
{
try {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_PAGE_UP);
robot.keyRelease(KeyEvent.VK_PAGE_UP);
} catch (Exception e) {
// Get the Exception for runtime task kill
e.printStackTrace();
}
}
|
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