Make an input field empty not working together with Knockout JS

3 posts, 1 answers
  1. Sander Notenbomer
    Sander Notenbomer avatar
    5 posts
    Member since:
    May 2009

    Posted 18 Jul 2012 Link to this post

    I have a simple website with 3 input boxes and a button which works together with Knockout JS for databinding.

    When I click on the button it will validate if the the input fields are not empty.
    When they are empty the background color changes to red else they become white.

    Now i want to test the following situation with a webtest:
    - Insert a value in the first input field (e.q. test)
    - hit the save button.
    - The first input field is white and input 2 and 3 are red.
    - Empty the first input field.
    - Click the save button again.
    - All the input fields are red.

    When a make a webtest for this situation it does not work. Because the value that was databinded to knockout wasn't cleared and the lest step of the situation fails because the first input stays white.

    I can not find a good solution to fix this.

    Please see the attached test project and website that will show the behavior.
  2. Answer
    Anthony avatar
    19 posts

    Posted 18 Jul 2012 Link to this post

    Hello Sander,

    Thank you for the project files. They were extremely helpful.

    The issue is with step 11. Injecting an empty string into the text field is not adequately clearing the stored text. Notice that during execution, the "test" string is still displayed to the right of the text field.

    To overcome this I disabled step 11 and added two new steps:
    • A Left Double Click Mouse Action from the Elements Menu. This will highlight the text during execution.
    • A Key Press of the Delete Key (not Backspace, but the Delete under the Insert Key). This will delete the highlighted text during execution.

    See the attached screen shot for more detail. The test passed after these changes.

    Kind regards,
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Sander Notenbomer
    Sander Notenbomer avatar
    5 posts
    Member since:
    May 2009

    Posted 19 Jul 2012 Link to this post

    Thanks for the  quick answer. It was really helpful.

    There was only one small thing that i need to add to the test. 

    When you enter an ip-adrress, for example, internet explorer only selects the last number after the dot. To fix this you need to initiate a single left click after the double-click. This will select the whole text.

    But that was a small thing that was easily fixed. Thanks again for the quick response and a working solution.
Back to Top