Forum Discussion

Bill_H's avatar
Bill_H
Occasional Contributor
4 days ago
Solved

Unable to save a value to DB

Hi all - 

I am working with a .Net application where I enter data (date) into a textbox then click other boxes etc. then save. On Save the date entered is not passed on to save - I have tried to enter text then tab, enter etc. and I can't get that date data to be saved.

I have tried to tab and enter on the mapped object as well as using Sys.Keys and neither works.

When I manually enter this date/data it is saved to the DB.

Unsure what to try next.

Thanks,

Bill

  • What keyboard key strokes you need to tap to set it correctly?

    Are you using code based script or KeywordTests script?

    How are you doing it programmatically? provide the example. From the documentation link I provided, the listed example to press the keyboard escape key is

    onscreenObj.Keys("[Esc]");

     

9 Replies

  • Bill_H's avatar
    Bill_H
    Occasional Contributor

    Thanks all ... Keys now seems to be working to set the data.

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    Are you able to provide a screenshot of you Object Browser, which includes the properties, for that control?

    What version of TestComplete are you using? 

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 3 rankChampion Level 3

    It sounds like the issue may be related to how the application detects user input versus how TestComplete is setting the value programmatically.

    If you're able to enter the date correctly using the keyboard manually, then the issue may be that the application requires real keyboard events to register the value properly.

    Until you're able to pinpoint the exact behavior of that control, I recommend using the Keys method in your script as a workaround https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/onscreen/keys-action-onscreen-object.html 

    This method simulates actual keystrokes and is often more reliable for inputs that trigger events on user interaction.

    🤖 AI-assisted response.
    💬 Was this helpful? Click Like to show appreciation.
    ✅ Got the answer you needed? Mark as Solution to help others find it too.

    • Bill_H's avatar
      Bill_H
      Occasional Contributor

      Thank you for the reply but I have tried Keys and Sys.Keys as well with no luck. I have also tried after that to tab/enter out of the field and still no  luck.

      • Hassan_Ballan's avatar
        Hassan_Ballan
        Icon for Champion Level 3 rankChampion Level 3

        What keyboard key strokes you need to tap to set it correctly?

        Are you using code based script or KeywordTests script?

        How are you doing it programmatically? provide the example. From the documentation link I provided, the listed example to press the keyboard escape key is

        onscreenObj.Keys("[Esc]");

         

  • scot1967's avatar
    scot1967
    Icon for Champion Level 2 rankChampion Level 2

    Hello Bill_H.

    I would also log the properties of the object after the the enter, tab etc.  I have seen apps do very odd things with .keys verses setText and weird things related to object focus.

    Another things to try is to record a script and perform the action manually.  If this works you should have a script example that works and you can fine tune and analyze actions from there.

    ... If you find my posts helpful drop me a like! 👍 Be sure to mark or post the solution to help others out and/or to credit the one who helped you. 😎

    • Bill_H's avatar
      Bill_H
      Occasional Contributor

      Hi there thanks for the suggestion - I actually did record the action and it used the methods I was. It does eventually pass a date but not the right date ... the field has type ahead and a date picker associated with it.  

      The issue I have is that when the 'right' date is set in the field and then I move out and click another setting and save the 'right' date doesn't seem to be committed so it is saved without the date. If I set the date then click out of it, in some cases, the date gets reset to today's date ( I am trying to pass yesterday's date) then I can save that. 

      I am flummoxed.

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    What version of TestComplete are you using? Can you see the date being entered in the field? Is it the correct format? If yes, use the Object Spy tool to verify that the field has actually been updated with your chosen date.