Run a key press event before or during application initialisation

4 posts, 0 answers
  1. Jakob
    Jakob avatar
    22 posts
    Member since:
    Mar 2014

    Posted 20 Sep Link to this post

    Hi,

     

    The issue I currently have is a little tricky to explain, so feel free to ask for clarification :)

    I’m running wpf. tests on an in-house application. Our application uses integrated logins, so usually when I do standard workflows, I let the app login automatically with my personal credentials. However, at times I need to log in as a different user. In daily use we do this by holding down F2 to break the integration and allow manual login.

    Previously I could accomplish this during testing by a small coded step with a keyboard.keyUp/Down event. However, this only worked because of an old inherent error in the test application that would cause the initialisation of the application to be halted until a dialogue was accepted, allowing us to insert the keyboard event before full app boot up.

    And now we get to the issue at hand: Since I updated to current version of Test Studio and Runtime, that particular error message caused TS to lose focus on start-up and the tests failed because of this. The developers then fixed the error, so the message would not appear and the tests would run alright. BUT, without the error message dialogue, the initialisation of the application is not paused by anything, and the keypress event doesn’t happen at the critical point. Thus, I never get the login box and am not able to proceed with these particular tests.

    So, based on this, can you think of a way to introduce the F2 key event at the moment of initialisation? Or alternatively, is there a way to pass arguments to execute the application so we can program a different start-up behaviour depending on the test?

     

    Thank you,

    Jakob

  2. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    254 posts

    Posted 22 Sep Link to this post

    Hello Jakob,

    The described scenario is not a common one though I will try to be of help for you. Test Studio offers a feature to include custom scripts before or after a test run. You could implement such in your project and press the F2 key in code. The line of code you need would be: 

    Manager.Desktop.KeyBoard.KeyPress(Keys.F2, 50, 1);

    You should consider that in the context of wpf test this will work in the following order - the application will be started, the custom script will be executed and then the execution of the test will start. Would that work for you? 

    Regards,
    Elena Tsvetkova
    Telerik by Progress
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. Jakob
    Jakob avatar
    22 posts
    Member since:
    Mar 2014

    Posted 22 Sep in reply to Elena Tsvetkova Link to this post

    Hi Elena

     

    Thank you for trying, but this will not work (we tried it just be sure, but no). We are already using the keypress(Keys.F2), problem is that we need it to take place before or at the same time as the application starts, because we need it to interrupt the normal login step. 

     

    Regards,
    Jakob

  4. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    254 posts

    Posted 26 Sep Link to this post

    Hi Jakob,

    I am sorry to hear my suggestion did not work for you. I understand what you actually require however I am not sure this could be obtained. Though I have one more idea that might work. At the beginning of the test you could add a coded step in which you could kill the started application and start it in code again but this time in the context of the execution. Would that be possible? 

    Please keep me posted. 

    Regards,
    Elena Tsvetkova
    Telerik by Progress
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top