How to check the excel value if its the same with the declared string in eclipse

Answered

I’m trying to create a method for my project which will automatically read a certain column on the excel data, and will sendKeys if the statement is true heres my code:


String sDirector = "83134235304";

String sIndividual = "66007826352";

String sPartnership = "63114774839";
try {
//Insert Australian Business Number Details

//If condition statement will check that if the Excel value for the ABN is for "sDirector", "sIndividual", "sPartnership" details
sAustralianBusinessNumber = ExcelUtils.getCellData(iTestCaseRow, Constant.COL_ABN);

if

(sAustralianBusinessNumber.equals(sDirector)){

Log.info("Australian Business Number picked from Excel is " + sAustralianBusinessNumber);

com.businessname.pageobjects.RegistrationPage.txtbx_AbnSearch().sendKeys(sDirector);

Log.info("Australian Business Number is entered in ABN search box");

}
else if(sAustralianBusinessNumber.equals(sIndividual)){

Log.info("Australian Business Number picked from Excel is " + sAustralianBusinessNumber);

com.businessname.pageobjects.RegistrationPage.txtbx_AbnSearch().sendKeys(sIndividual);

Log.info("Australian Business Number is entered in ABN search box");

}
else if(sAustralianBusinessNumber.equals(sPartnership)){

Log.info("Australian Business Number picked from Excel is " + sAustralianBusinessNumber);

com.businessname.pageobjects.RegistrationPage.txtbx_AbnSearch().sendKeys(sPartnership);

Log.info("Australian Business Number is entered in ABN search box");

}
//Click action

//Register "Your Business Details"

com.businessname.pageobjects.RegistrationPage.btn_CheckAbn().click();

Log.info("Click action performed on Check ABN button");

com.businessname.pageobjects.RegistrationPage.btn_AbnYes().click();

Log.info("Click action performed on Yes button");
}catch(Exception e){
Log.error("Australian Business Number is either Invalid or not existing on the testData!");
throw(e);
}

}
}

The problem is when i run the code, it does not send any keys on the txtbx_AbnSearch.
it ignores the nested if statement and continues on the click action, does my if statement has an logical error? Ive been debbuging that for 3 hrs already. Can someone help me on this one?

Thanks in advance

Heres my testData:

 How to check the excel value if its the same with the declared string in eclipse

Supporter Asked on August 28, 2014 in Selenium WebDriver.

hi luckperez

Your Code Seems Fine to me
try sAustralianBusinessNumber in a Hardcoded Way
May be it will Help You Debugging Your Code

on August 28, 2014.
Add Comment
  • 1 Answer(s)
    Best answer

    hi luckperez

    You Can Try a Few Things

    1 =  You Can Try Using sAustralianBusinessNumber.trim().equals(sDirector.trim())

    as it Will Remove All Leading and Trailing Spaces

    2= Print The Values sAustralianBusinessNumber Before Using it so To Make Sure That You Have the Correct Value

    let me know if any of them Works

    thanks

    ankit

    Vice Professor Answered on August 28, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.