Ask a Question

Calculate length of excel cell

shilpi_agarwal
Contributor

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 5
baxatob
Community Hero

Re: Calculate length of excel cell

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.

Colin_McCrae
Community Hero

Re: Calculate length of excel cell

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
Community Hero

Re: Calculate length of excel cell

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


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
shilpi_agarwal
Contributor

Re: Calculate length of excel cell

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)

Marsha_R
Community Hero

Re: Calculate length of excel cell

That will work but it would be a more generic test to look at the length of the string instead of the contents.

 

Take a look at aqString.Compare

https://support.smartbear.com/viewarticle/87967/

 

You can check the numeric requirement separately.

 

 


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
cancel
Showing results for 
Search instead for 
Did you mean: