Topic
  • 7 replies
  • Latest Post - ‏2013-10-25T12:37:57Z by TonyNGAN
TonyNGAN
TonyNGAN
34 Posts

Pinned topic Pause Script

‏2013-10-18T06:24:15Z |

Dear All,

May I know if I want to pause a script during playback, how should I code the script?

My teammate has tried

pause();

But it doesn't work event imported the required component.

Many Thanks

Best Regards

Tony

  • MrCoolK
    MrCoolK
    58 Posts
    ACCEPTED ANSWER

    Re: Pause Script

    ‏2013-10-18T12:20:32Z  

    Sleep is all you need syntax sleep(timeinsecond);

    you can try object.waitforexistence();-this will make the playback pause until that object is visible

    Press F12 while the script is running will pause the script

    Thanks

    Cool K

  • Raman_Sm
    Raman_Sm
    3 Posts

    Re: Pause Script

    ‏2013-10-18T10:54:43Z  

    1. pause the script by the code *within* the script

    2. do anything on the next line of code (which is within the script also)

     

    If the 1. actually stopped (paused) the script - how the 2. will be executed actually (the script was paused as you may guess)?

     

    if run the following *within* the script:

     

    Dim NeedPause As New Rational.Test.Ft.Services.PlaybackMonitorNeedPause.Pause()' got exception System.InvalidOperationException: Cross-thread operation not valid: Control 'PlaybackMonitor' accessed from a thread other than the thread it was created on.
    

     

    Dim NeedPause As Rational.Test.Ft.Services.IPlaybackMonitorNeedPause = GetPlaybackMonitor()NeedPause.Pause()' actually does nothing - script is going (though the PlayBack Monitor shows that it is "paused" :) )
    

     

    I suppose those lines of code should be "outside" of the RFT code to make it really working - e.g. launch RFT in that code, set the script to run, get the PlayBack Monitor, etc. - it is what Visual Studio actually does when it executes the RFT script.

    Updated on 2013-10-18T10:55:30Z at 2013-10-18T10:55:30Z by Raman_Sm
  • ChrisGF
    ChrisGF
    163 Posts

    Re: Pause Script

    ‏2013-10-18T10:58:28Z  

    Hi, If some visiual component appears on the screen after the request you can add for example (in case of an IDialoge or some other object)

    loginPanel().waitForExistence();

    so you pause as long as it appers (after all the work was done in the background)

    you can also use sleep(seconds) like sleep(4); or sleep(1.500);

    hope it helps,

    Krisz

    Updated on 2013-10-18T10:59:53Z at 2013-10-18T10:59:53Z by ChrisGF
  • MrCoolK
    MrCoolK
    58 Posts

    Re: Pause Script

    ‏2013-10-18T12:20:32Z  

    Sleep is all you need syntax sleep(timeinsecond);

    you can try object.waitforexistence();-this will make the playback pause until that object is visible

    Press F12 while the script is running will pause the script

    Thanks

    Cool K

  • TonyNGAN
    TonyNGAN
    34 Posts

    Re: Pause Script

    ‏2013-10-19T13:14:03Z  
    • Raman_Sm
    • ‏2013-10-18T10:54:43Z

    1. pause the script by the code *within* the script

    2. do anything on the next line of code (which is within the script also)

     

    If the 1. actually stopped (paused) the script - how the 2. will be executed actually (the script was paused as you may guess)?

     

    if run the following *within* the script:

     

    <pre dir="ltr">Dim NeedPause As New Rational.Test.Ft.Services.PlaybackMonitorNeedPause.Pause()' got exception System.InvalidOperationException: Cross-thread operation not valid: Control 'PlaybackMonitor' accessed from a thread other than the thread it was created on. </pre>

     

    <pre dir="ltr">Dim NeedPause As Rational.Test.Ft.Services.IPlaybackMonitorNeedPause = GetPlaybackMonitor()NeedPause.Pause()' actually does nothing - script is going (though the PlayBack Monitor shows that it is "paused" :) ) </pre>

     

    I suppose those lines of code should be "outside" of the RFT code to make it really working - e.g. launch RFT in that code, set the script to run, get the PlayBack Monitor, etc. - it is what Visual Studio actually does when it executes the RFT script.

    Dear Raman_Sm,

    Thanks for your reply. But I need to try on coming monday if the about suggestion works :)

    Regards!

    Tony

  • TonyNGAN
    TonyNGAN
    34 Posts

    Re: Pause Script

    ‏2013-10-19T13:17:24Z  
    • ChrisGF
    • ‏2013-10-18T10:58:28Z

    Hi, If some visiual component appears on the screen after the request you can add for example (in case of an IDialoge or some other object)

    loginPanel().waitForExistence();

    so you pause as long as it appers (after all the work was done in the background)

    you can also use sleep(seconds) like sleep(4); or sleep(1.500);

    hope it helps,

    Krisz

    Dear Krisz,

    Thanks :)! But sorry that .waitForExistence(); is not suitable for my script as my teammate want to pause the whole playback until someone take action after the page loaded.

    Thus, sleep() is also not suitable for us.

    We want the RTF can pause once the page loaded.

    Anyway, may thanks for your suggestion :)!

    Regards

    Tony

  • TonyNGAN
    TonyNGAN
    34 Posts

    Re: Pause Script

    ‏2013-10-19T13:19:06Z  
    • MrCoolK
    • ‏2013-10-18T12:20:32Z

    Sleep is all you need syntax sleep(timeinsecond);

    you can try object.waitforexistence();-this will make the playback pause until that object is visible

    Press F12 while the script is running will pause the script

    Thanks

    Cool K

    Dear Cool K,

    Woo! You have inspired me!

    I may use the script to press F12 to pause the RFT playback on any line :)!

    Will try this way:)!

    Many Thanks!

    Regards

    Tony

  • TonyNGAN
    TonyNGAN
    34 Posts

    Re: Pause Script

    ‏2013-10-25T12:37:57Z  
    • MrCoolK
    • ‏2013-10-18T12:20:32Z

    Sleep is all you need syntax sleep(timeinsecond);

    you can try object.waitforexistence();-this will make the playback pause until that object is visible

    Press F12 while the script is running will pause the script

    Thanks

    Cool K

    Hi Cool K,

    Thanks for your inspiring :)!!!

    I can use Java Robot to press F12 and the PlayBackMonitor can stops whenever I want!

    Many Thanks!

    Best Regards

    Tony