Forum Discussion

gilshalev's avatar
gilshalev
Occasional Contributor
14 years ago

Few questions...


Hi



I'm a new user to TC (but have a lot of expirience in QTP).

Few issues that bother me:

1. Scripts and Keyword are seperated tests?! Meaning if I did a change in keyword I allready converted to script, i need to reconvert?

2. How to do a simple sync (E.g. wait for a window). I saw "exist" but without a time parameter?!

3. When a checkpoint fails, the test stops. How can I control it?

4. I added an ADO connection to keyword. Now... what to do with it? How to use it's methods etc? I know how to do it in scripting...

5. Same with conditions added to Keyword.



Thanks alot.



Gil

7 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    1. Scripts and Keyword are seperated tests?! Meaning if I did a change in keyword I allready converted to script, i need to reconvert?


    When you convert a keyword test to script code, there is no link preserved between the two.  They are, as you noted, now two seperate tests.  The purpose of keyword tests is to provide an interface to create automated tests via a visual UI for test developers that may have minimal or no experience writing code.  Since you're a former QTP user, you may find working with script tests easier than keyword tests.



    2. How to do a simple sync (E.g. wait for a window). I saw "exist" but without a time parameter?!


    If you're using a Keyword test, you can use the "If Object" operation (see http://smartbear.com/support/viewarticle/14494/) to detect when an object exists.  By default, the amount of time for the test is determined by the auto-wait timeout in the project properties (see http://smartbear.com/support/viewarticle/11191/) but it can be over-ridden on a per-operation basis by right clicking on the desired operation and selecting the option from the context menu (see http://smartbear.com/support/viewarticle/12921/)



    If you're using script code, there are a variety of methods commonly designated as "WaitNNN" methods (examples are WaitChild, WaitVCLObject, WaitAliasChild, etc).  This article describes the basics of waiting for an object to exist for both keyword tests and script code http://smartbear.com/support/viewarticle/14496/.  For the specific variety or object context that you are working on you'll need to make a determination of which Wait method to use.



    3. When a checkpoint fails, the test stops. How can I control it?


    There are several settings that make this determination.  Again, on project properties | playback there is a setting for "stop on error".  Since a checkpoint failure logs an error, that fires this option and stops the test.  The other setting is on the test item itself within your project test items list (see http://smartbear.com/support/viewarticle/11001/).  Judicial use of these options can control when your project stops and when it doesn't.

    4. I added an ADO connection to keyword. Now... what to do with it? How to use it's methods etc? I know how to do it in scripting...




    When working with such objects in a keyword test, you'll need to set the result of the ADO.CreateConnection to a variable using the Set Variable operation and use the "Last Operation Result" as the value to which you'll set the variable.



    Between you and me, I prefer to do these kinds of processes in script as it is more intuitive to someone who knows script programming code.  You can call script code, then, within a keyword test.



    5. Same with conditions added to Keyword.




    I'm not sure what you're asking here.  Are you adding "If/then" logic to a keyword test?  If so, what are you trying to do with it that is not working?  Can you provide a screenshot to demonstrate what you've attempted?



    Hopefully I've been able to answer most of your questions.  Let me know if there is anything more I can do.
  • gilshalev's avatar
    gilshalev
    Occasional Contributor
    Thanks alot for the detailed and fast answers!!!

    What I meant in my last question, is how I add statments in Keyword inside conditions, or for example, when i ask about object.exist I want to get the result and behave accordingly.

    I guess you answered taht one regarding the ADO question so i will try it.



    Thanks,



    Gil
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Indenting an operation that follows an if statement makes it an operation dependant upon the if statement.  Give that a shot.
  • gilshalev's avatar
    gilshalev
    Occasional Contributor
    Hi



    We both agree that scripting is more flexible once you have the knowledge.

    Still, in keyword, , let's say I created an ADO object and set it to a variable.

    Is there a way than in keyword to do:

    varADO.ConnectionString = "..."

    varADO.Execute...

    Etc...
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The best way I know of to do that within a keyword is to use the "Run Code Snippet" operation because you'll need to manually key in the keyword variable designation and the assignment to the necessary value.  


  • gilshalev's avatar
    gilshalev
    Occasional Contributor
    Thanks alot, picture is getting clearer!



    So if I want to combine my own scripting in keyword, i can either:

    Run cone snippet, script routine or test, correct?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    That is correct.  A code snippet, though, must be a single statement.  You cannot run blocks of code in a code snippet.  For that, it's best to call a script routine.