Thread.sleep alternative for Coded Steps in Telerik Test Studio

6 posts, 0 answers
  1. mamta
    mamta avatar
    1 posts
    Member since:
    Nov 2014

    Posted 23 Nov 2014 Link to this post

    Thread.sleep alternative for Coded Steps in Telerik Test Studio:

    I don't want to use Thread.sleep as it fails the test cases at some time, what should be used to replace it.
    As an example, I have windows to find which doesn't have captions so I am not able to find the windows through wait for window.
    The only option that I have is to find the windows through last window caption and that works only if I put thread.sleep before it.

    Please let me know if there is any other alternative to it.

    Required help on urgent basis, any help would be appreciated.


    Thanks
    Mamta
  2. Mamta
    Mamta avatar
    3 posts
    Member since:
    Aug 2014

    Posted 17 Dec 2014 Link to this post

    Hello Telerik Admin,

    Could you please reply on it as I need it urgently for my project and also I am using licensed Telerik tool.

    Thanks
    Mamta
  3. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 17 Dec 2014 Link to this post

    Hello Mamta,

    I already did back on November 25th. I never got a response to the additional questions I asked. Here is my last response repeated, of which I need your answers:

    What type of application are you trying to automate, WPF or Web/Silverlight? Please share with us the code you are currently using. Screen shots of these windows you are trying to connect to would also be useful.

    I have to admit, based on your description of the problem, I fail to understand how you're getting this to work at all. Normally Test Studio can only connect to windows that have a title/caption. Without a caption I'm not aware of any method of connecting to the window to automate it.



    Regards,
    Cody
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  4. Mamta
    Mamta avatar
    3 posts
    Member since:
    Aug 2014

    Posted 18 Dec 2014 in reply to Cody Link to this post

    Hello Cody,

    I am trying to automate a WPF App. and there are couple of windows in my app that doesn't have title. So what I am doing is , I am finding the entire list of WPF windows and then looking for the last window and its caption. This way I am able to get the window which is not having title as well.

    Below is a sample of code  where in I am finding a window Gast Details with the below code

     var windowslist1 = wpfApp.Windows.ToList();
     var lastcaption1 = windowslist1.Last().Window.Caption;
      var GastDetails = wpfApp.WaitForWindow(lastcaption1.ToString(), 20000);

    Thread.Sleep(2000);
    GastDetails.Find.ByName<Button>(AppSettings.Default.GastDetailsCheckinButton).User.Click();

    So to perform any action on Gast Details window, I have to put Sleep before that then only its able to do so. Otherwise the command fails as its not able to load gast details by that time.
    But the problem is the screen loading time varies at different environments so the testing which is passing at my end sometimes fails at other machines but when I increase the sleep time, it passes.


    Attached the screenshots as well:
      

  5. Mamta
    Mamta avatar
    3 posts
    Member since:
    Aug 2014

    Posted 21 Dec 2014 Link to this post

    Hello Cody,

    Please reply now as I have mentioned the details that you asked, need help urgently.

    Thanks
    Mamta
  6. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 22 Dec 2014 Link to this post

    Hi Mamta,

    The two screen shots are identical. I do see a title of "Gastsuche" on the window. As far as Test Studio is concerned window title = window caption.

    If the test script is trying to click on the button before it exists, you can add a line of code to wait for it to exist before clicking on it like this:

    AppSettings.Default.GastDetailsCheckinButton.Wait.ForExists(2000);

    Use this in place of the Thread.Sleep(2000);

    P.S. Public forum posts have a guaranteed response time of 72 business hours, not 24 business hours. We do not work weekends, thus we do not count weekends.


    Regards,
    Cody
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!