/**
* @author:Soumya.D
*
* Contains Code related sahi actions and methods
*/
package com.hr.generic;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.File;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.Map;
import config.Constants;
import net.sf.sahi.client.Browser;
import net.sf.sahi.client.ElementStub;
import com.hr.automation.sahi.Button;
import com.hr.automation.sahi.CheckBox;
import com.hr.automation.sahi.Div;
import com.hr.automation.sahi.Image;
import com.hr.automation.sahi.Password;
/*import com.hr.automation.sahi.SahiSuit;*/
import com.hr.automation.sahi.Span;
import com.hr.automation.sahi.TableCell;
import com.hr.automation.sahi.TextArea;
import com.hr.automation.sahi.TextBox;
import com.hr.automation.utilities.Accessories;
import config.Constants;
public class GenericActionKeywords extends DriverScript {
static SimpleDateFormat dateformat = new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
static Date d = new Date();
public void launchAndNavigate(ArrayList<String> testData) throws Throwable
{
try
{
browser = new Browser(testData.get(0));
configProps.setProperty("BrowserType", testData.get(0));
browser.open();
// writing URL to configprops to use URL for recovery scenarios
//configProps.setProperty("URL", testData.get(1));
// browser.navigateTo(testData.get(1));
CommonKeywords.getURL();
browser.navigateTo(configProps.getProperty("URL"));
}
catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method launchAndNavigate | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return;
}
DriverScript.bResult = true;
}
public void login(ArrayList<String> objectIdentifier,ArrayList<String> testData) throws Throwable
{
try
{
if (browser.heading3("Sahi 5xx Error").exists())
{
DriverScript.bResult = false;
return;
}
configProps.setProperty("UserName", testData.get(0));
configProps.setProperty("Password", testData.get(1));
configProps.setProperty("UserNameIdentifier", objectIdentifier.get(0));
configProps.setProperty("PasswordIdentifier", objectIdentifier.get(1));
if (TextBox.setText(objectIdentifier.get(0), testData.get(0)) == false)
{
DriverScript.bResult = false;
return;
}
if (Password.setPassword(objectIdentifier.get(1), testData.get(1)) == false)
{
DriverScript.bResult = false;
return;
}
if (Button.click("Submit") == false)
{
DriverScript.bResult = false;
return;
}
if (browser.label("Invalid Credentials.").exists())
{
DriverScript.bResult = false;
return;
}
if (browser.heading1("Some Technical error occured").exists())
{
if (recoveryScenario.someTechincalError())
{
DriverScript.bResult = false;
return;
}
}
if (browser.span("Unable to login with the credentials provided. Please login again.").exists())
{
if (recoveryScenario.unableToLoginWithCredentials())
{
DriverScript.bResult = false;
return;
}
}
if (Span.isSpanExist("Confirm"))
{
if (recoveryScenario.singleUserLogin())
{
DriverScript.bResult = false;
return;
}
}
DriverScript.bResult = true;
}
catch (Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method login | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return;
}
}
public static void closeBrowser() throws Throwable
{
try {
Log.info("Closing the browser");
browser.kill();
browser.close();
}
catch (Exception e)
{
Log.error("Class GenericActionKeywords | Method closeBrowser | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
}
public void navigateToSubTab(ArrayList<String> objectIdentifier)throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
if (Span.isSpanExist(objectIdentifier.get(0)))
{
if (Span.click(objectIdentifier.get(0)) == false)
{
DriverScript.bResult = false;
return;
}
}
else
{
DriverScript.bResult = false;
return;
}
browser.setStrictVisibilityCheck(false);
Thread.sleep(2000);
browser.setStrictVisibilityCheck(true);
if (Span.isSpanExist(objectIdentifier.get(1)))
{
if (Span.click(objectIdentifier.get(1)) == false)
{
DriverScript.bResult = false;
return;
}
}
else
{
DriverScript.bResult = false;
return;
}
browser.setStrictVisibilityCheck(false);
}
catch(Exception e)
{
Log.error("Class GenericActionKeywords | Method navigateToSubTab | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
e.printStackTrace();
return;
}
DriverScript.bResult = true;
}
public void buttonClick(ArrayList<String> objectIdentifier) throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
if (!Button.isButtonDisabled(objectIdentifier.get(0)))
{
browser.button(objectIdentifier.get(0).toString()).click();
}
else
{
DriverScript.bResult = false;
return;
}
Thread.sleep(10000);
browser.setStrictVisibilityCheck(false);
}
catch (Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method buttonClick | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return;
}
DriverScript.bResult = true;
}
public void uploadFile(ArrayList<String> objectIdentifier,ArrayList<String> testData) throws Throwable
{
try
{
String urlToUpload = getUploadUrl(testData.get(0));
String attachFilePath = Constants.Path_Uploads+"\\"+testData.get(1);
if (configProps.getProperty("BrowserType").equalsIgnoreCase("ie")) {
browser.focusWindow();
browser.waitFor(1000);// needed
// focus on the element
browser.focus(browser.file("attachment"));
// click "space" to bring up the browser dialog
Robot r2 = new Robot();
r2.keyPress(java.awt.event.KeyEvent.VK_SPACE);
// java.awt.event.KeyEvent.VK_SPACE
browser.waitFor(1000);
// type the file path
if (!typeNative(attachFilePath)) {
DriverScript.bResult = false;
return;
}
browser.waitFor(1000);
// press enter
r2.keyPress(java.awt.event.KeyEvent.VK_ENTER);
browser.waitFor(1000);
}
else
{
browser.setStrictVisibilityCheck(true);
browser.setFile2(browser.file(objectIdentifier.get(0)),
attachFilePath, urlToUpload);
Thread.sleep(10000);
browser.execute("_sahi._call(_sahi._textbox('"
+ objectIdentifier.get(1) + "').value='"
+ attachFilePath + "');");
browser.waitFor(10000);
browser.setStrictVisibilityCheck(false);
}
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method uploadFile | Exception desc : "+e.getMessage());
return;
}
DriverScript.bResult = true;
}
public boolean typeNative(String str) throws NoSuchFieldException,SecurityException, IllegalArgumentException, IllegalAccessException
{
Robot robot = null;
try
{
robot = new Robot();
}
catch (AWTException e)
{
e.printStackTrace();
return false;
}
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
int keyCode = Character.codePointAt(str, i);
boolean shiftKey = false;
switch (c) {
case '~': {
shiftKey = true;
keyCode = KeyEvent.VK_BACK_QUOTE;
break;
}
case '`': {
keyCode = KeyEvent.VK_BACK_QUOTE;
break;
}
case '!': {
shiftKey = true;
keyCode = KeyEvent.VK_1;
break;
}
case '@': {
shiftKey = true;
keyCode = KeyEvent.VK_2;
break;
}
case '#': {
shiftKey = true;
keyCode = KeyEvent.VK_3;
break;
}
case '$': {
shiftKey = true;
keyCode = KeyEvent.VK_4;
break;
}
case '%': {
shiftKey = true;
keyCode = KeyEvent.VK_5;
break;
}
case '^': {
shiftKey = true;
keyCode = KeyEvent.VK_6;
break;
}
case '&': {
shiftKey = true;
keyCode = KeyEvent.VK_7;
break;
}
case '*': {
shiftKey = true;
keyCode = KeyEvent.VK_8;
break;
}
case '(': {
shiftKey = true;
keyCode = KeyEvent.VK_9;
break;
}
case ')': {
shiftKey = true;
keyCode = KeyEvent.VK_0;
break;
}
case '_': {
shiftKey = true;
keyCode = KeyEvent.VK_MINUS;
break;
}
case '+': {
shiftKey = true;
keyCode = KeyEvent.VK_EQUALS;
break;
}
case '{': {
shiftKey = true;
keyCode = KeyEvent.VK_OPEN_BRACKET;
break;
}
case '}': {
shiftKey = true;
keyCode = KeyEvent.VK_CLOSE_BRACKET;
break;
}
case ':': {
shiftKey = true;
keyCode = KeyEvent.VK_SEMICOLON;
break;
}
case '\"': {
shiftKey = true;
keyCode = KeyEvent.VK_QUOTE;
break;
}
case '\'': {
keyCode = KeyEvent.VK_QUOTE;
break;
}
case '<': {
shiftKey = true;
keyCode = KeyEvent.VK_COMMA;
break;
}
case '>': {
shiftKey = true;
keyCode = KeyEvent.VK_PERIOD;
break;
}
case '?': {
shiftKey = true;
keyCode = KeyEvent.VK_SLASH;
break;
}
case '\\': {
keyCode = KeyEvent.VK_BACK_SLASH;
break;
}
}
if ((keyCode >= 97 && keyCode <= 122)
|| (keyCode >= 65 && keyCode <= 90)) {
shiftKey = (keyCode >= 65 && keyCode <= 90);
String variableName = "VK_" + ("" + c).toUpperCase();
Class clazz = KeyEvent.class;
Field field = clazz.getField(variableName);
keyCode = field.getInt(null);
}
if (shiftKey)
robot.keyPress(KeyEvent.VK_SHIFT);
try {
robot.keyPress(keyCode);
robot.keyRelease(keyCode);
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (shiftKey)
robot.keyRelease(KeyEvent.VK_SHIFT);
}
}
return true;
}
public String getUploadUrl(String uploadURL) {
String uploadUrl = null;
try
{
if (configProps.getProperty("URL").contains("stag")) {
uploadUrl = "https://ondemandstag.receivablesradius.com/RRDMSProject/dms/"
+ uploadURL;
} else if (configProps.getProperty("URL").contains("test")) {
uploadUrl = "https://ondemandtest.receivablesradius.com/RRDMSProject/dms/"
+ uploadURL;
} else {
uploadUrl = "https://ondemand.receivablesradius.com/RRDMSProject/dms/"
+ uploadURL;
}
}
catch(Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method getUploadUrl | Exception desc : "+e.getMessage());
return null;
}
return uploadUrl;
}
public boolean selectDropDownValueByLabel(ArrayList<String> objectIdentifier, ArrayList<String> testData)throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
browser.image("/x-form-trigger x-form-arrow-/")
.near(browser.label(objectIdentifier.get(0).toString()))
.click();
browser.div(testData.get(0).toString())
.in(browser.div("/x-layer x-combo-list/")).click();
browser.setStrictVisibilityCheck(false);
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method selectDropDownValueByLabel | Exception desc : "+e.getMessage());
return false;
}
DriverScript.bResult = true;
return true;
}
public void advancedSearchByMultipleFeilds(ArrayList<String> objectIdentifier, ArrayList<String> testData) throws Throwable
{
// ArrayList<String> elementIdentifier=new ArrayList<>();
// elementIdentifier.add(0, "div_Payment Batches");
if (!advancedSearchStart()) {
DriverScript.bResult = false;
return;
}
if (!setMultipleFieldsDatabyType(objectIdentifier, testData)) {
DriverScript.bResult = false;
return;
}
if (!advancedSearchEnd()) {
DriverScript.bResult = false;
return;
}
DriverScript.bResult = true;
}
public boolean setMultipleFieldsDatabyType( ArrayList<String> objectIdentifier, ArrayList<String> testData) throws Throwable
{
try {
ArrayList<String> identifier = new ArrayList<String>();
ArrayList<String> data = new ArrayList<String>();
if (!(objectIdentifier.size() == testData.size()))
{
System.out.println("objectIdentifier and testdata size is different");
DriverScript.bResult = false;
return false;
}
for (int i = 0; i < objectIdentifier.size(); i++)
{
String a = objectIdentifier.get(i);
identifier.add(0, a);
data.add(0, testData.get(i));
if (!setValueByFieldType(identifier, data))
{
identifier.remove(0);
data.remove(0);
DriverScript.bResult = false;
return false;
}
identifier.remove(0);
data.remove(0);
}
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method setMultipleFieldsDatabyType | Exception desc : "+e.getMessage());
return false;
}
DriverScript.bResult = true;
return true;
}
public enum FieldType {
TEXTBOX, TEXTAREA, DROPDOWN, PICKLIST;
}
public boolean setValueByFieldType(ArrayList<String> objectIdentifier,ArrayList<String> testData) throws Throwable
{
try
{
String[] objectIdentifiers = objectIdentifier.get(0).split("~");
ArrayList<String> identifier = new ArrayList<String>();
browser.setStrictVisibilityCheck(true);
switch (FieldType.valueOf(objectIdentifiers[0])) {
case TEXTBOX:
if (!TextBox.setText(objectIdentifiers[1], testData.get(0))) {
DriverScript.bResult = false;
return false;
}
break;
case TEXTAREA:
if (!TextArea.setText(objectIdentifiers[1], testData.get(0))) {
DriverScript.bResult = false;
return false;
}
break;
case DROPDOWN:
identifier.add(0, objectIdentifiers[1]);
if (!selectDropDownValueByLabel(identifier, testData))
{
DriverScript.bResult = false;
return false;
}
break;
case PICKLIST:
identifier.add(0, objectIdentifiers[1]);
identifier.add(1, objectIdentifiers[2]);
identifier.add(2, objectIdentifiers[3]);
identifier.add(3, objectIdentifiers[4]);
identifier.add(4, objectIdentifiers[5]);
browser.setStrictVisibilityCheck(true);
if (!selectValueFromPickList(identifier, testData))
{
DriverScript.bResult = false;
return false;
}
break;
}
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method setValueByFieldType | Exception desc : "+e.getMessage());
return false;
}
DriverScript.bResult = true;
return true;
}
public boolean selectValueFromPickList(ArrayList<String> objectIdentifier, ArrayList<String> testData)
throws Throwable {
try {
try {
System.out.println(objectIdentifier.size());
System.out.println(objectIdentifier.get(4));
browser.setStrictVisibilityCheck(true);
if(objectIdentifier.get(4).equalsIgnoreCase("textbox"))
{
browser.image(Integer.parseInt(objectIdentifier.get(1))).near(browser.textbox(objectIdentifier.get(0))).click();
}
else if(objectIdentifier.get(4).equalsIgnoreCase("label"))
{
browser.image(Integer.parseInt(objectIdentifier.get(1))).near(browser.label(objectIdentifier.get(0))).click();
}
} catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method selectValueFromPickList | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return false;
}
browser.setStrictVisibilityCheck(false);
if (browser.div(objectIdentifier.get(2)).exists()) {
browser.textbox(Integer.parseInt(objectIdentifier.get(3)))
.near(browser.div(objectIdentifier.get(2)))
.setValue(testData.get(0));
browser.execute("_sahi._keyPress(_sahi._textbox(1, _sahi._near(_sahi._div('"
+ objectIdentifier.get(2) + "'))),[13,13])");
try {
browser.setStrictVisibilityCheck(true);
browser.div(testData.get(0))
.near(browser.div(objectIdentifier.get(2))).click();
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method selectValueFromPickList | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return false;
}
if (!Button.click("Select")) {
DriverScript.bResult = false;
return false;
}
if (browser.span("Please select a record.").exists()) {
DriverScript.bResult = false;
return false;
}
} else {
DriverScript.bResult = false;
return false;
}
} catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method selectValueFromPickList | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
return true;
}
public boolean advancedSearchStart() throws Throwable {
try {
browser.setStrictVisibilityCheck(true);
if (Button.click("/Advanced Search/") == false) {
DriverScript.bResult = false;
return false;
}
if (Button.click("/Clear/") == false) {
DriverScript.bResult = false;
return false;
}
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method advancedSearchStart | Exception desc : "+e.getMessage());
return false;
}
DriverScript.bResult = true;
return true;
}
public boolean advancedSearchEnd() throws Throwable {
try
{
browser.setStrictVisibilityCheck(true);
if (Button.click("/^Search/") == false) {
DriverScript.bResult = false;
return false;
}
if (Button.click("/Hide/") == false) {
DriverScript.bResult = false;
return false;
}
browser.setStrictVisibilityCheck(false);
}
catch(Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method advancedSearchEnd | Exception desc : "+e.getMessage());
return false;
}
DriverScript.bResult = true;
return true;
}
public void waitForElement(ArrayList<String> ObjectIdentifiers)
throws Throwable {
try {
ElementStub elem = new ElementStub(ObjectIdentifiers.get(0).split(
"~")[0], browser, ObjectIdentifiers.get(0).split("~")[1]);
int waitCount = 1;
do {
if (waitCount >= 21)
break;
waitCount++;
Thread.sleep(3000);
} while (!elem.exists());
} catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method waitForElement | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return;
}
DriverScript.bResult = true;
}
public long getTotalRecordsFromTheGrid(ArrayList<String> ObjectIdentifiers)
throws Throwable {
long totalRecordsCount = 0;
Thread.sleep(10000);
refreshGrid();
browser.setStrictVisibilityCheck(true);
if (Div.isDivExist("x-grid-empty") == true) {
totalRecordsCount = 0;
DriverScript.dynamicValue.put(sdynamicValueName,String.valueOf(totalRecordsCount));
return totalRecordsCount;
} else {
try {
browser.setStrictVisibilityCheck(true);
String recordCount = browser
.fetch("_sahi._div({className:'xtb-text',id:'/ext-comp-/',sahiText:'/"
+ ObjectIdentifiers.get(0) + "/'}).innerHTML");
browser.setStrictVisibilityCheck(false);
totalRecordsCount = Long.parseLong(recordCount.split("of")[1]
.trim());
DriverScript.dynamicValue.put("totCountOfRecords",String.valueOf(totalRecordsCount));
DriverScript.dynamicValue.put(sdynamicValueName,String.valueOf(totalRecordsCount));
} catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method getTotalRecordsFromTheGrid | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return 0;
}
}
browser.setStrictVisibilityCheck(true);
DriverScript.bResult = true;
return totalRecordsCount;
}
public void refreshGrid() throws Throwable {
try {
browser.setStrictVisibilityCheck(true);
if (Button.isButtonVisible("/ x-btn-text x-tbar-loading/")) {
if (!Button.click("/ x-btn-text x-tbar-loading/")) {
DriverScript.bResult = false;
return;
}
} else {
DriverScript.bResult = false;
return;
}
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method refreshGrid | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return;
}
DriverScript.bResult = true;
}
public void validateIfMultupleRecordsExistWithSameField(
ArrayList<String> ObjectIdentifiers) throws Throwable {
long numOfRec = getTotalRecordsFromTheGrid(ObjectIdentifiers);
if (numOfRec != 1 ) {
DriverScript.bResult = false;
return;
} else {
DriverScript.bResult = true;
}
}
public void doubleClickOnFirstRecord(ArrayList<String> ObjectIdentifiers)
throws Throwable {
try {
String randomvalue=browser.div(0)
.under(browser.div(ObjectIdentifiers.get(0).toString())).getText();
browser.div(0)
.under(browser.div(ObjectIdentifiers.get(0).toString()))
.doubleClick();
DriverScript.dynamicValue.put("randomValue", randomvalue);
DriverScript.dynamicValue.put(sdynamicValueName, randomvalue);
} catch (Exception e) {
DriverScript.bResult = false;
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method doubleClickOnFirstRecord | Exception desc : "+e.getMessage());
return;
}
DriverScript.bResult = true;
}
public boolean validateActualValueInDetailsOrGrid(
String typeOfnearByOrUnderEl, String nearByOrUnderEl,
int posNearOrUnderEl, String compareValue, String action,
String gridOrDetails, String scenario) throws Throwable {
browser.setStrictVisibilityCheck(true);
String valueInApp = "";
Thread.sleep(10000);
switch (typeOfnearByOrUnderEl) {
case "LABEL":
valueInApp = browser.div(posNearOrUnderEl)
.near(browser.label(nearByOrUnderEl)).getText();
break;
case "DIV":
valueInApp = browser.div(posNearOrUnderEl)
.under(browser.div(nearByOrUnderEl)).getText();
break;
default:
break;
}
System.out.println("value in app:=>" + valueInApp);
System.out.println("compare value is:=>" + compareValue);
if (valueInApp.equals(compareValue)) {
} else {
return false;
}
browser.setStrictVisibilityCheck(false);
return true;
}
public void verifyCountofRecordsOnGrid(ArrayList<String> ObjectIdentifiers)
throws Throwable {
long totalNumberOfRecords = getTotalRecordsFromTheGrid(ObjectIdentifiers);
if (totalNumberOfRecords == 0 || totalNumberOfRecords == -1) {
Log.info("Total number of records on the Grid:"
+ totalNumberOfRecords);
comments="Records are not available on the grid to edit/delete/unlink/print";
DriverScript.bResult = false;
} else {
Log.info("Total number of records on the Grid:"
+ totalNumberOfRecords);
DriverScript.bResult = true;
}
}
/**
* By Divya on Jun 23 to select the random number from the grid
*/
public void selectRecordRandomlyFromGrid(ArrayList<String> ObjectIdentifiers)
throws Throwable {
try {
int randumNumber = getRandumNumberFromTheGrid(ObjectIdentifiers
.get(0).toString());
Thread.sleep(3000);
configProps.setProperty("RANDUMNUMBER",
String.valueOf(randumNumber));
browser.setStrictVisibilityCheck(true);
String value = browser.div(randumNumber)
.under(browser.div(ObjectIdentifiers.get(1).toString()))
.getText();
Thread.sleep(3000);
browser.div(randumNumber)
.under(browser.div(ObjectIdentifiers.get(1).toString()))
.click();
//DriverScript.dynamicValue.put("randomRecordValue", value);
DriverScript.dynamicValue.put(sdynamicValueName, value);
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
DriverScript.bResult = false;
}
}
/**
* By Divya on Jun 23 to get the random number from the grid
*/
public int getRandumNumberFromTheGrid(String gridrecordCountText)
throws Throwable {
int recRandNum = 0;
try {
browser.setStrictVisibilityCheck(true);
String recCount = browser
.fetch("_sahi._div({className:'xtb-text',sahiText:'/"
+ gridrecordCountText + "/'}).innerHTML");
browser.setStrictVisibilityCheck(false);
String gridRec = recCount.split("-")[1].trim();
int Max = Integer.parseInt(gridRec.split("of")[0].trim());
int Min = 1;
recRandNum = Min + (int) (Math.random() * ((Max - Min) + 1));
recRandNum = recRandNum - 1;
return recRandNum;
} catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method getRandumNumberFromTheGrid | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
return recRandNum;
}
public void splitButtonClick(ArrayList<String> ObjectIdentifiers)
throws Throwable {
try {
browser.setStrictVisibilityCheck(true);
TableCell.nearByClick(ObjectIdentifiers.get(0).toString(),
browser.emphasis(ObjectIdentifiers.get(1).toString()));
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
Log.error("Class ActionsKeyWord | Method SplitButtonClick | Exception desc : "
+ e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void spanClick(ArrayList<String> ObjectIdentifiers) throws Throwable
{
try
{
if(isSpanExist(ObjectIdentifiers))
{
browser.setStrictVisibilityCheck(true);
browser.span(ObjectIdentifiers.get(0)).click();
browser.setStrictVisibilityCheck(false);
DriverScript.bResult = true;
}
}
catch (Exception e)
{ e.printStackTrace();
Log.error("Class GenericActionKeywords | Method spanClick | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
}
public boolean isSpanExist(ArrayList<String> objectIdentifier)throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
if(Span.isSpanExist(objectIdentifier.get(0)) == true)
{
DriverScript.bResult = true;
browser.setStrictVisibilityCheck(false);
return true;
}
else
{
DriverScript.bResult = false;
browser.setStrictVisibilityCheck(false);
return false;
}
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method isSpanExist | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
browser.setStrictVisibilityCheck(false);
return false;
}
}
/**By Divya
* To Select the Check Box
* Parameters:Identifier of the checkbox*/
public void selectCheckBox(ArrayList<String> objectIdentifier) throws Throwable
{
try
{
if(CheckBox.isCheckboxExist(objectIdentifier.get(0)))
{
browser.setStrictVisibilityCheck(true);
browser.checkbox(objectIdentifier.get(0)).check();
browser.setStrictVisibilityCheck(false);
}
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult=false;
Log.error("Class GenericActionKeywords | Method selectCheckBox | Exception desc : "+e.getMessage());
}
DriverScript.bResult = true;
}
public void checkRadioButton(ArrayList<String> objectIdentifier) throws Throwable
{
try
{
if(browser.radio(objectIdentifier.get(0)).exists())
{
browser.setStrictVisibilityCheck(true);
browser.radio(objectIdentifier.get(0)).click();
browser.setStrictVisibilityCheck(false);
}
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult=false;
Log.error("Class GenericActionKeywords | Method checkRadioButton | Exception desc : "+e.getMessage());
}
DriverScript.bResult=true;
}
public int getDropDownItems(ArrayList<String> objectIdentifier)
{
int dropdownCount=0;
try
{
browser.setStrictVisibilityCheck(true);
browser.image("/x-form-trigger x-form-arrow-/").
near( browser.textbox(objectIdentifier.get(0))).click();
Thread.sleep(8000);
dropdownCount = browser.div("/x-combo-list-item/").in(browser.div("/x-combo-list-inner/")).countSimilar();
browser.image("/x-form-trigger x-form-arrow-/").near( browser.textbox(objectIdentifier.get(0))).click();
browser.setStrictVisibilityCheck(false);
String CountOfRecords=String.valueOf(dropdownCount);
DriverScript.dynamicValue.put("CountOfRecorsdInDropDown", CountOfRecords);
}catch (Exception e) {
e.printStackTrace();
DriverScript.bResult=false;
Log.error("Class GenericActionKeywords | Method getDropDownItems | Exception desc : "+e.getMessage());
}
DriverScript.bResult=true;
return dropdownCount;
}
public void countOfRecordsInDropDownBeforeOrAfter(ArrayList<String> ObjectIdentifiers,ArrayList<String> testData) throws Throwable
{
try
{
if(testData.contains("before"))
{
int numOfRecBefore = getDropDownItems(ObjectIdentifiers);
DriverScript.dynamicValue.put("numOfRecBefore", String.valueOf(numOfRecBefore));
Log.info("Before Count"+numOfRecBefore);
}
else
{
int numOfRecAfter= getDropDownItems(ObjectIdentifiers);
DriverScript.dynamicValue.put("numOfRecAfter", String.valueOf(numOfRecAfter));
Log.info("Before Count"+numOfRecAfter);
}
}
catch (Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method countOfRecordsInDropDownBeforeOrAfter | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void clickonclosebutton(ArrayList<String> ObjectIdentifiers) throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
browser.div("/x-tool-close/").near(browser.span(ObjectIdentifiers.get(0).toString())).click();
browser.setStrictVisibilityCheck(false);
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method clickonclosebutton | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void countValidationAfterAdvancedSearch(
ArrayList<String> ObjectIdentifiers,ArrayList<String> testData) throws Throwable {
try
{
long noOfRec = Long.parseLong(testData.get(0).toString());
long numOfRec = getTotalRecordsFromTheGrid(ObjectIdentifiers);
if (numOfRec == noOfRec ) {
DriverScript.bResult = true;
} else {
DriverScript.bResult = false;
}
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method clickonclosebutton | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void countOfRecordsOnGridBeforeAndAfter(ArrayList<String> ObjectIdentifiers, ArrayList<String> testData) throws Throwable
{
try
{
if(testData.get(0).toString().contains("Before"))
{
long numOfRecBefore = getTotalRecordsFromTheGrid(ObjectIdentifiers);
DriverScript.dynamicValue.put("numOfRecBefore", String.valueOf(numOfRecBefore));
Log.info("Before count"+numOfRecBefore);
}
else
{
long numOfRecAfter= getTotalRecordsFromTheGrid(ObjectIdentifiers);
DriverScript.dynamicValue.put("numOfRecAfter", String.valueOf(numOfRecAfter));
Log.info("After count"+numOfRecAfter);
}
DriverScript.bResult = true;
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method countOfRecordsOnGridBeforeAndAfter | Exception desc : "+e.getMessage());
}
}
public void countValidationBeforeAndAfter(ArrayList<String> testData) throws Throwable
{
try
{
long numOfRecBefore=Long.parseLong(testData.get(0).toString());
long numOfRecAfter=Long.parseLong(testData.get(1).toString());
long number=Long.parseLong(testData.get(2));
if (numOfRecBefore+number == numOfRecAfter )
{
DriverScript.bResult = true;
} else
{
DriverScript.bResult = false;
}
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method countValidationBeforeAndAfter | Exception desc : "+e.getMessage());
}
}
public void selectDropDownValue(ArrayList<String> objectIdentifier, ArrayList<String> testData)throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
browser.image("/x-form-trigger x-form-arrow-/").
near( browser.textbox(objectIdentifier.get(0).toString())).click();
browser.div(testData.get(0).toString())
.in(browser.div("/x-layer x-combo-list/")).click();
browser.setStrictVisibilityCheck(false);
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method selectDropDownValue | Exception desc : "+e.getMessage());
}
DriverScript.bResult = true;
}
public void addTimeStampToVariable(ArrayList<String> testData)throws Throwable
{
try
{
DriverScript.dynamicValue.put("timeStopValue",testData.get(0).concat(Accessories.timeStamp()));
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method addTimeStampToVariable | Exception desc : "+e.getMessage());
}
DriverScript.bResult = true;
}
public void closeOtherTabs(ArrayList<String> objectIdentifier){
try
{
browser.setStrictVisibilityCheck(true);
browser.span(objectIdentifier.get(0)).rightClick();
browser.span("Close Other Tabs").click();
browser.setStrictVisibilityCheck(false);
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method closeOtherTabs | Exception desc : "+e.getMessage());
}
DriverScript.bResult = true;
}
public void nearByClickOnImage(ArrayList<String> objectIdentifier) throws Throwable
{
browser.setStrictVisibilityCheck(true);
try
{
if(Image.nearByClick(0, browser.label(objectIdentifier.get(0)))==false)
{
DriverScript.bResult = false;
}
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
browser.setStrictVisibilityCheck(false);
DriverScript.bResult = true;
}
public void nearBySetTextInTextbox(ArrayList<String> objectIdentifier,ArrayList<String> testData) throws Throwable
{
browser.setStrictVisibilityCheck(true);
try
{
if(TextBox.nearBySetText(1, browser.span(objectIdentifier.get(0)), testData.get(0))==false)
{
DriverScript.bResult = false;
}
else
{
browser.execute("_sahi._keyPress(_sahi._textbox(1, _sahi._near(_sahi._div(\""+objectIdentifier.get(0)+"\"))),[13,13])");
}
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
browser.setStrictVisibilityCheck(false);
}
public void divClick(ArrayList<String> objectIdentifier) throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
if(Div.click(objectIdentifier.get(0))==false)
{
DriverScript.bResult = false;
}
browser.setStrictVisibilityCheck(false);
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void divDoubleClick(ArrayList<String> objectIdentifier) throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
if(Div.doubleClick(objectIdentifier.get(0))==false)
{
DriverScript.bResult = false;
}
browser.setStrictVisibilityCheck(false);
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method divDoubleClick | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void selectMultipleRecordsRandomlyFromGrid(ArrayList<String> ObjectIdentifiers)
throws Throwable {
int randumNumber1;
int randumNumber2;
try {
randumNumber1 = getRandumNumberFromTheGrid(ObjectIdentifiers
.get(0).toString());
randumNumber2 = getRandumNumberFromTheGrid(ObjectIdentifiers
.get(0).toString());
while(randumNumber1==randumNumber2)
{
randumNumber2 = getRandumNumberFromTheGrid(ObjectIdentifiers
.get(0).toString());
}
Thread.sleep(3000);
browser.setStrictVisibilityCheck(true);
String values1 = browser.div(randumNumber1)
.under(browser.div(ObjectIdentifiers.get(1).toString()))
.getText();
String values2 = browser.div(randumNumber2)
.under(browser.div(ObjectIdentifiers.get(1).toString()))
.getText();
Thread.sleep(3000);
browser.div(randumNumber1)
.under(browser.div(ObjectIdentifiers.get(1).toString()))
.click();
Thread.sleep(3000);
browser.click(browser.div(randumNumber2)
.under(browser.div(ObjectIdentifiers.get(1).toString())),"CTRL");
DriverScript.dynamicValue.put("randomRecordValues", values1+","+values2);
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method selectMultipleRecordsRandomlyFromGrid | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public boolean isDivExist(ArrayList<String> objectIdentifier)throws Throwable
{
try
{
if(!Div.isDivExist(objectIdentifier.get(0)))
{
DriverScript.bResult = false;
return false;
}
else
{
DriverScript.bResult = true;
}
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method isDivExist | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return false;
}
return true;
}
public String appendRandomNumToString(ArrayList<String> testData)throws Throwable
{
String testDataMod;
try
{
int Min=1;
int Max=2000;
int randNum=Min + (int)(Math.random() * ((Max - Min) + 1));
testDataMod=testData.get(0)+randNum;
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method appendRandomNumToString | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return null;
}
DriverScript.bResult = true;
return testDataMod;
}
public void selectNumberFromDropDown(ArrayList<String> objectIdentifier, ArrayList<String> testData)throws Throwable
{
try
{
Thread.sleep(10000);
browser.setStrictVisibilityCheck(true);
/*browser.image("/x-form-trigger x-form-arrow-/")
.near(browser.label(objectIdentifier.get(0).toString()))
.click();*/
BigDecimal bd = new BigDecimal(testData.get(0));
long it=bd.longValue();
String value=String.valueOf(it);
Double num=Double.parseDouble(testData.get(0));
System.out.println("num"+num);
browser.image("/x-form-trigger x-form-arrow-/").
near( browser.textbox(objectIdentifier.get(0).toString())).click();
browser.div(value)
.in(browser.div("/x-layer x-combo-list/")).click();
browser.setStrictVisibilityCheck(false);
}
catch (Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method selectNumberFromDropDown | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void divUnderClick(ArrayList<String> objectIdentifier) throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
browser.div(objectIdentifier.get(1)).under(browser.div(objectIdentifier.get(0))).click();
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method divUnderClick | Exception desc : "+e.getMessage());
}
DriverScript.bResult = true;
}
public void getDownloadSession() throws Throwable
{
try
{
browser.sendHTMLResponseAfterFileDownload(true);
browser.addToSession(CommonKeywords.addToSessionURL());
}catch (Exception e) {
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method getDownloadSession | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void downloadPopupWindow(ArrayList<String> testData) throws Throwable
{
try
{
//attach path
String attachFilePath;
if(System.getProperty("os.name").contains("Linux"))
{
attachFilePath=baseProjectPath.concat("/Results/");
}else
{
attachFilePath=baseProjectPath.concat("\\Results\\");
}
//download path
String downloadPath=attachFilePath.concat(testData.get(0)+"[" + CommonKeywords.getStartTime() + "].pdf");
String s1=browser.lastDownloadedFileName() ;
int p=1;
while( p==1)
{
browser.execute("_sahi._wait(120000, _sahi._lastDownloadedFileName() != null);");
if(!(browser.lastDownloadedFileName()==null))
{
browser.saveDownloadedAs(downloadPath);
break;
}
}
s1=browser.lastDownloadedFileName();
Log.info("Last downloaded file:");
Log.debug(s1);
browser.clearLastDownloadedFileName();
System.out.println("last downloaded file:"+s1);
browser.popup("/File Downloaded/").link("Close Window").click();
//file check
File f = new File(downloadPath);
if(f.exists())
{
Log.info("File exists");
comments="Sucessfully downloaded the file";
}
else
{
Log.info("File not found!");
comments="Failed to download the file";
DriverScript.bResult = false;
}
}catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method downloadPopupWindow | Exception desc : "+e.getMessage());
}
DriverScript.bResult = true;
}
public void getCurrentDate()throws Throwable
{
try
{
DriverScript.dynamicValue.put("dateValue",Accessories.dateFormate());
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method addTimeStampToVariable | Exception desc : "+e.getMessage());
}
DriverScript.bResult = true;
}
public void nearByClick(ArrayList<String> objectIdentifier) throws Throwable
{
browser.setStrictVisibilityCheck(true);
try
{
if(Span.nearByClick(objectIdentifier.get(0), browser.span(objectIdentifier.get(1)))==false)
{
DriverScript.bResult = false;
return;
}
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
browser.setStrictVisibilityCheck(false);
DriverScript.bResult = true;
}
public void selectFirstRecordFromPickList(ArrayList<String> objectIdentifier)
throws Throwable {
try {
browser.setStrictVisibilityCheck(true);
if(TextBox.isTextboxExist(objectIdentifier.get(1)))
{
browser.image(Integer.parseInt(objectIdentifier.get(2))).near(browser.textbox(objectIdentifier.get(1))).click();
long numOfRecords=getTotalRecordsFromTheGrid(objectIdentifier);
System.out.println("No of records"+numOfRecords);
if(numOfRecords >= 1)
{
browser.div(objectIdentifier.get(4))
.under(browser.div(objectIdentifier.get(3))).click();
String value=browser.div(objectIdentifier.get(4))
.under(browser.div(objectIdentifier.get(3))).getText();
dynamicValue.put("recordText", value);
if (!Button.click("Select")) {
DriverScript.bResult = false;
}
if (browser.span("Please select a record.").exists()) {
browser.div(objectIdentifier.get(3))
.under(browser.div(objectIdentifier.get(2))).click();
}
browser.setStrictVisibilityCheck(false);
}
else
{
comments="There are no records to select value from picklist";
DriverScript.bResult = false;
}
}
} catch (Exception e) {
e.printStackTrace();
browser.image(Integer.parseInt(objectIdentifier.get(2)))
.near(browser.textbox(objectIdentifier.get(1))).highlight();
Log.error("Class GenericActionKeywords | Method selectFirstRecordFromPickList | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
DriverScript.bResult = true;
}
public void selectFirstValueFromDropdown(ArrayList<String> objectIdentifier)throws Throwable
{
String Item1;
try
{
browser.setStrictVisibilityCheck(true);
browser.image("/x-form-trigger x-form-arrow-/").
near( browser.textbox(objectIdentifier.get(0).toString())).click();
long dropdownCount = browser.div("/x-combo-list-item/").in(browser.div("/x-combo-list-inner/")).countSimilar();
String Item=browser.div(1)
.in(browser.div("/x-layer x-combo-list/")).getText();
if(!Item.equals(""))
{
browser.div(1)
.in(browser.div("/x-layer x-combo-list/")).click();
dynamicValue.put(sdynamicValueName,Item);
}
else if(dropdownCount > 1)
{
Item1=browser.div(2)
.in(browser.div("/x-layer x-combo-list/")).getText();
browser.div(2)
.in(browser.div("/x-layer x-combo-list/")).click();
dynamicValue.put(sdynamicValueName,Item1);
browser.setStrictVisibilityCheck(false);
}
else
{
Log.info("There are no items under dropdown");
DriverScript.bResult = false;
return;
}
}
catch (Exception e)
{
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method selectFirstValueFromDropdown | Exception desc : "+e.getMessage());
return;
}
DriverScript.bResult = true;
}
public boolean isLinkExist(ArrayList<String> objectIdentifier)throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
if(browser.link(objectIdentifier.get(0)).exists()==true)
{
browser.link(objectIdentifier.get(0)).highlight();
}
browser.setStrictVisibilityCheck(false);
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class GenericActionKeywords | Method isLinkExist | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
return false;
}
DriverScript.bResult = true;
return true;
}
public void logout()
{
browser.setStrictVisibilityCheck(true);
try
{
if(browser.heading3("Sahi 5xx Error").exists())
{
bResult = false;
return ;
}
if(Button.click(" x-btn-text icon-gear"))
{
bResult = true;
}
else
{
bResult = false;
return ;
}
if(Span.click("Logout"))
{
bResult = true;
}
else
{
bResult = false;
return ;
}
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
browser.setStrictVisibilityCheck(false);
bResult = true;
}
public void reLogin() throws Throwable
{
//Logout
try
{
logout();
ArrayList<String> loginIdentifiers = new ArrayList<String>();
ArrayList<String> loginCrendentials= new ArrayList<String>();
loginIdentifiers.add(0,configProps.getProperty("UserNameIdentifier"));
loginIdentifiers.add(1,configProps.getProperty("PasswordIdentifier"));
loginCrendentials.add(0,configProps.getProperty("UserName"));
loginCrendentials.add(1,configProps.getProperty("Password"));
login(loginIdentifiers, loginCrendentials);
bResult = false;
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
bResult = false;
}
}
public void nearByButtonClick(ArrayList<String> objectIdentifier) throws Throwable
{
browser.setStrictVisibilityCheck(true);
try
{
browser.button(objectIdentifier.get(0)).near(browser.span(objectIdentifier.get(1))).click();
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
browser.setStrictVisibilityCheck(false);
DriverScript.bResult = true;
}
public void divInByButtonClick(ArrayList<String> objectIdentifier) throws Throwable
{
browser.setStrictVisibilityCheck(true);
try
{
browser.button(objectIdentifier.get(0)).in(browser.div(objectIdentifier.get(1))).click();
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
browser.setStrictVisibilityCheck(false);
DriverScript.bResult = true;
}
public void divNearByDivClick(ArrayList<String> objectIdentifier,ArrayList<String> testData) throws Throwable
{
browser.setStrictVisibilityCheck(true);
try
{
browser.div(testData.get(0).toString()).near(browser.div(objectIdentifier.get(0))).click();
}
catch(Exception e)
{
e.printStackTrace();
Log.error("Class "+this.getClass().getName()+" | Method "+Thread.currentThread().getStackTrace()[1].getMethodName()+" | Exception desc : "+e.getMessage());
DriverScript.bResult = false;
}
browser.setStrictVisibilityCheck(false);
DriverScript.bResult = true;
}
public void divUnderClickByIndex(ArrayList<String> objectIdentifier) throws Throwable
{
try
{
browser.setStrictVisibilityCheck(true);
browser.div(Integer.parseInt(objectIdentifier.get(1))).under(browser.div(objectIdentifier.get(0))).click();
browser.setStrictVisibilityCheck(false);
} catch (Exception e) {
e.printStackTrace();
DriverScript.bResult = false;
Log.error("Class GenericActionKeywords | Method divUnderClickByIndex | Exception desc : "+e.getMessage());
}
DriverScript.bResult = true;
}
}
Monday, August 29, 2016
GenericActionKewords
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment