Forum Discussion

shilpi_agarwal's avatar
shilpi_agarwal
Contributor
8 years ago

Calculate length of excel cell

Application UI validation of Postal code field for customer add screen says -

 "Postal code is not valid. It should be 6 digit and numeric".

Question is -

1. Do I need to create test data for 1 digit, 2 digit, 3 digit till 5 digit in excel file? I mean to say these 5 records should exist in the excel file to validate the Postal Code? 

2. Suppose Excel file have test data named "Postal Code" and value is 123.

In script, How to check the length of Postal code cell in script? or Do I need to check with the same test data as in below example.

Currently I am using with same test data in excel-

if aqConvert.VarToStr(Driver.Value(6)) = "123" then
  "fill all the fields of application and checkpoint to compare the application actual output with the excel file's expected output."

 

Please suggest.

5 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    I believe it's enough to have 3 test-cases for the mentioned event:

    one for <6 digits,

    one for >6 digits,

    and one for alphanumerical postal code with 6 symbols.

  • Depends on a couple of things:

     

    1. The country you're talking about. Can't be the UK if it's 6 digit numeric. UK is Alpha + Numeric and if you want to validate your input, a big horrible regex is about as good as it gets.

     

    2. Are you 100% controlling the test data? Or are you writing something other people can populate and use thus you need to validate their input data. If you're the one in control, then this is a simple test and the answer from baxatob should be sufficient. (Although I would probably add a check for leaving it blank ...)

    • Marsha_R's avatar
      Marsha_R
      Champion Level 3

      I would add the =6 digits case, since that's the actual requirement.

      • shilpi_agarwal's avatar
        shilpi_agarwal
        Contributor

        My question is - 

        Since i am hard coding the postal code in my script. Is this correct way to use hardcode the value of postal code in the script?

        if aqConvert.VarToStr(Driver.Value(6)) = "123" then

        Here I am checking the postal code value with the excel file's postal code and compare the expected output(in excel file) with the actual output(application output)