Forum Discussion

SubhraDas's avatar
SubhraDas
New Contributor
13 days ago

Delay after pressing specific Key

Hi, I am migrating several hundreds of "Microfocus Test Partner"  tests to Test Complete which are created a decade ago. Because there is no clear migration path only way left is to play Test Partner tests and let Test Complete records it. This approach works fairly well, however I have a bit of problem where Test Partner is pressing "[F10]" to perform a save operation on the application under test (AUT). Test Partner performs kind of `thread.sleep(n)` and because the recording in Test Complete is not done using real time which I don't want so there is no delay in the recorded script after Keys("[F10]") and tests are failing. It's really inefficient to tackle this problem manually by entering aqUtils.Delay(n) after each Keys("[F10]"). 

So, my question would be is there a way, possibly some Even stuff in Tests Complete to address this issue . i.e. after Keys("[F10]") only a wait will be called,  If so how. A  pseudo code example or steps would be helpful . Or any other way to handle this ? 

Cheers

Thanks

5 Replies

  • SubhraDas's avatar
    SubhraDas
    New Contributor

    well I think `aqObject` cannot be extended, prototyped for a new function equivalent to `Keys()` so that I can replace existing `Keys()` with `CustomKeys()` where  `CustomKeys()` can handle a delay when "[F10]" is used.

    Neither we can override  

    Only dirty way is 

    // Custom function to simulate pressing keys with a delay after pressing F10
    function Save (obj) {
      let keySequence = "[F10]"
      let cardPanel = object;
      let d = cardPanel.FindChild("JavaClassName", "regexp:.*DataForm.*");
      let dataForm = d.FindChild("JavaClassName", "regexp:.*JScrollPane.*").FindChild("JavaClassName", "regexp:.*JViewport.*")
        dataForm.Keys(keySequence);
        // Check if the key sequence contains "[F10]"
        if (keySequence.indexOf("[F10]") !== -1) {
            // Add a delay after pressing F10
            aqUtils.Delay(1000,"saving form data"); // Adjust the delay time as needed
        }
    }
    module.exports.Save = Save;

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Key press followed by a 5 second delay,

    Obj.Keys("[F10]");
    aqUtils.Delay(5000);

     

    • SubhraDas's avatar
      SubhraDas
      New Contributor

      That's not what I want . I want Keys function to know if it's getting "[F10]" and do stuff. I want to modify the Keys function i.e. override or extend aqObject / testObject

       

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        If you want to override the method, search the internet for "how to override a JavaScript function", if using JavaScript.

        I'm not sure if it's possible in the version of JavaScript, that TC uses.

        You pass the constant value i.e. "[F10]" to the Keys method, which will then simulate the keystroke to the object. You can then proceed to perform other actions.