Null values in excel databind file

2 posts, 0 answers
  1. Beckie
    Beckie avatar
    7 posts
    Member since:
    Nov 2010

    Posted 03 Dec 2010 Link to this post

    Is there a setting somewhere to allow null values from a data bound file?   I have several rows of data (excel file) for creating a request in our system, some of which have nothing in some of the cells, so that no data is filled in for that field on the screen.   I know I can catch it in the code-behind, but I was hoping there is a setting somewhere to handle empty cells as empty string or some other elegant solution.  I have a lot of steps that I would have to handle in the code-behind if there is no setting.
  2. Stoich
    Stoich avatar
    1 posts

    Posted 06 Dec 2010 Link to this post

    Hi Beckie,

       You shouldn't have any problems with Null values. Here's how it works: you can create an Excel Sheet with multiple columns, like this:

    1| fName | lName     |
    2| Tom     | Roger      |       
    3| Dick     | Foreman |
    4|              | Paul         |
    5| Harry   |                  |
    And lets say you bind a test to this excel. Your test handles a login - it writes a first and last name to two Input boxes. The two "Set Text To" steps for these text boxes are bound to the excel  $(fName) and $(lName) respectively.

    When you execute this it will be broken down into 4 iterations. Each iteration will use the values from one row. The empty (null) values will be treated as simply empty - you won't get a nullpointer exception even if you don't check for it in a coded step. For the specific example shown above the four iterations will look like this value-wise:

    1)  $(fName)=Tom   and $(lName)=Roger
    2)  $(fName)=Dick   and $(lName)=Foreman
    3)  $(fName)=           and $(lName)=Paul  --> won't write anything to First Name Field
    4)  $(fName)=Harry and $(lName)=           --> won't write anything to Last Name Field

    And this test run will be completely successful - so no need to handle anything. Any null values are treated as an empty string ( "" ).

    I hope I've managed to answer your question please don't hesitate to contact us if there's anything else!

    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Back to Top