NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

public void input_MandatoryField(HashMap<String,String> stepDetails, Map<String,String> testData)
{
try
{
String value=testData.get(stepDetails.get("Field Name"));
By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
WebElement element= waitForElementToBeClickable(locator, 30);
element.clear();
element.sendKeys(value);
}
catch (Exception e)
{
e.printStackTrace();
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 click(HashMap<String,String> stepDetails, Map<String,String> testData) throws Exception
{
try
{
By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
waitForElementToBeClickable(locator,50).click();
}
catch (Exception e) {
e.printStackTrace();
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 click_usingEnterKey(HashMap<String,String> stepDetails, Map<String,String> testData) throws Exception
{
try
{
By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
waitForElementToBeClickable(locator,50).sendKeys(Keys.ENTER);
}
catch (Exception e) {
e.printStackTrace();
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 click_Optional(HashMap<String,String> stepDetails, Map<String,String> testData) throws Exception
{
try
{
String value=testData.get(stepDetails.get("Field Name"));
if(value.equals(null) || value.equals("")|| value.equalsIgnoreCase("NA")||value.equalsIgnoreCase("No"))
{
log.info(stepDetails.get("Field Name")+" 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();
}

}
catch (Exception e) {
e.printStackTrace();
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 Exter_click(HashMap<String,String> stepDetails, Map<String,String> testData) throws Exception
{
try
{
String data=testData.get(stepDetails.get("Field Name"));
String tempLocatorValue=stepDetails.get("Locator Value");
String updatedLocatorValue=tempLocatorValue.replace("Dummy", data);
By locator = findByLocator(stepDetails.get("Locator Type"),updatedLocatorValue);
waitForElementToBeClickable(locator,50).click();
}
catch (Exception e)
{
e.printStackTrace();
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";
}
}


public void Exter_click_optional(HashMap<String,String> stepDetails, Map<String,String> testData) throws Exception
{
try
{
String value=testData.get(stepDetails.get("Field Name"));
if(value.equals(null) || value.equals("")|| value.equalsIgnoreCase("NA") )
{
log.info(stepDetails.get("Field Name")+" is not applicable for this transaction (as per the testData)");
}
else
{
String tempLocatorValue=stepDetails.get("Locator Value");
String updatedLocatorValue=tempLocatorValue.replace("Dummy", value);
By locator = findByLocator(stepDetails.get("Locator Type"),updatedLocatorValue);
waitForElementToBeClickable(locator, 50).click();
}

}
catch (Exception e)
{
e.printStackTrace();
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";
}
}

public void click_ifEnabled_otherwiseContinue(HashMap<String,String> stepDetails, Map<String,String> testData)
{
try
{
boolean status;
WebDriverWait wait= new WebDriverWait(driver,Integer.parseInt(stepDetails.get("WaitTime")));
By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
WebElement ele=wait.until(ExpectedConditions.elementToBeClickable(locator));
status=ele.isEnabled();

if(status){
log.info(""+stepDetails.get("Field Name")+" is enabled");
ele.click();
}
}
catch (Exception e)
{
//e.printStackTrace();
String message=""+stepDetails.get("Field Name")+" is not enabled. Continue execution";
log.info(message);
}
}
public void clickOnVerifyEnableTrue(HashMap<String,String> stepDetails, Map<String,String> testData) throws MyException,Exception
{
try
{
By locator = findByLocator(stepDetails.get("SupportingElement_1_LocatorType"),stepDetails.get("SupportingElement_1_LocatorValue"));
waitFor(stepDetails, testData);
driver.findElement(locator).isEnabled();
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);
DriverScript.bResult = "fail";
DriverScript.eMessage = message;
}
catch (Exception e)
{
// e.printStackTrace();
By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
WebElement element = waitForElementToBeClickable(locator, 30);
try {
element.click();
} catch (Exception e1) {
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);
DriverScript.bResult = "fail";
DriverScript.eMessage = message;
}


}
}


public void failWhenEncounterSpecifiedText(HashMap<String,String> stepDetails, Map<String,String> testData) throws MyException,Exception
{
try
{
By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
waitFor(stepDetails, testData);
String text= driver.findElement(locator).getText().trim();
if (text.equalsIgnoreCase(stepDetails.get("ExpectedValue")))
{
String message =""+stepDetails.get("Field Name")+" failed. Please refer "+ testData.get("TestCaseName")+ ".jpg for more details";
log.info(message);
DriverScript.bResult = "fail";
DriverScript.eMessage = message;
}
}
catch (Exception e) {
e.printStackTrace();
log.info(e.getMessage());
log.info("Nick name is not unique. Continue test run");
}
}
public void input_select_VerifySingleListElement_optional( final 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(stepDetails.get("Field Name")+" is not applicable for this transaction (as per the testData)");
}
else
{
input_MandatoryField(stepDetails, testData);
waitFor(stepDetails, testData);

//Find dropdown list
By locator = findByLocator(stepDetails.get("SupportingElement_1_LocatorType"),stepDetails.get("SupportingElement_1_LocatorValue"));
WebElement dd=waitForElementToBeClickable(locator, 50);

List<WebElement> list=dd.findElements(By.tagName("li"));
waitFor(stepDetails, testData);
if(list.size()==1)//If drop down contains only one value then only we will select
{
new WebDriverWait(driver, 20).ignoring(StaleElementReferenceException.class).until(new Predicate<WebDriver>()
{
@Override
public boolean apply(@Nullable WebDriver driver)
{
By locator = findByLocator(stepDetails.get("SupportingElement_2_LocatorType"),stepDetails.get("SupportingElement_2_LocatorValue"));
waitForElementToBeClickable(locator, 60);
return true;
}
});

By ListElement_locator = findByLocator(stepDetails.get("SupportingElement_2_LocatorType"),stepDetails.get("SupportingElement_2_LocatorValue"));
waitForElementToBeClickable(ListElement_locator, 60).click();
}
else
{
log.info("Please provide valid account no");
//fail the test
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);
DriverScript.bResult = "fail";
DriverScript.eMessage = message;
}
}
}
catch (Exception e) {
//e.printStackTrace();
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 input_select_VerifySingleListElement( final HashMap<String,String> stepDetails, Map<String,String> testData) throws MyException,Exception
{
try
{

input_MandatoryField(stepDetails, testData);
waitFor(stepDetails, testData);

//Find dropdown list
By locator = findByLocator(stepDetails.get("SupportingElement_1_LocatorType"),stepDetails.get("SupportingElement_1_LocatorValue"));
WebElement dd=waitForElementToBeClickable(locator, 50);

List<WebElement> list=dd.findElements(By.tagName("li"));
waitFor(stepDetails, testData);
if(list.size()==1)//If drop down contains only one value then only we will select
{
new WebDriverWait(driver, 20).ignoring(StaleElementReferenceException.class).until(new Predicate<WebDriver>()
{
@Override
public boolean apply(@Nullable WebDriver driver)
{
By locator = findByLocator(stepDetails.get("SupportingElement_2_LocatorType"),stepDetails.get("SupportingElement_2_LocatorValue"));
waitForElementToBeClickable(locator, 60);
return true;
}
});

By ListElement_locator = findByLocator(stepDetails.get("SupportingElement_2_LocatorType"),stepDetails.get("SupportingElement_2_LocatorValue"));
waitForElementToBeClickable(ListElement_locator, 60).click();
}
else
{
log.info("Please provide valid account no");
//fail the test
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);
DriverScript.bResult = "fail";
DriverScript.eMessage = message;
}
}
catch (Exception e) {
//e.printStackTrace();
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 input_and_select_optionalField_enable( final HashMap<String,String> stepDetails, Map<String,String> testData) throws MyException,Exception
{
String value=testData.get(stepDetails.get("Field Name"));
if (value.equals("")|| value.equalsIgnoreCase("NA") ) {
log.info(stepDetails.get("Field Name")+" is not applicable for this transaction (as per the testData)");
}
else
{
try
{

By locator = findByLocator(stepDetails.get("Locator Type"),stepDetails.get("Locator Value"));
WebElement element= waitForElementToBeVisible(locator, 30);
if(element.isEnabled())
{
element.clear();
element.sendKeys(value);
}
else
{
element.click();
}
//input_MandatoryField(stepDetails, testData);
waitFor(stepDetails, testData);
//Find dropdown list
locator = findByLocator(stepDetails.get("SupportingElement_1_LocatorType"),stepDetails.get("SupportingElement_1_LocatorValue"));
WebElement dd=waitForElementToBeClickable(locator, 30);
List<WebElement> list=dd.findElements(By.tagName("li"));
for(WebElement temp:list)
{
String str=temp.getText();
if(str.contains(value))
{
temp.click();
break;
}
}
}
catch (Exception e) {
e.printStackTrace();
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;
}
}
}
     
 
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.