qtp faq's 2

Upload: 452bob

Post on 01-Jun-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 QTP Faq's 2

    1/29

    What are the Run modes in QTP ?

    There are 2 run modes in QTP* Normal : It shows the execution of your QTP script step by step. This works ood in case of debuin your script.* !ast "un : It will not show the execution line by line.

    What are the Debugging modes used in QTP ?

    #ifferent #ebuin modes used in QTP are* $tep Into : To run only the current line of the acti%e test or component.* $tep &ut : "uns to the end of the called action or user'defined function( then returns to the callin action and pauses therun session.* $tep &%er : to run only the current step in the acti%e test or component. )hen the current step calls another action or auser'defined function(the called action or function is executed entirety( but the called action script is not displayed in theQuickTest window.

    What are the draw backs of QTP ?

    #isad%antaes are* QTP takes %ery lon to open hue tests. lso +P, utili-ationbecomes //0 in that case.* QTP scripts are hea%y as it stores all the html files 1for acti%e screen as well.* 3lock commentin is not pro%ided till 4.2 %ersion.

    What are the extension of file..........

    * Per test object repositor: filename.mtr 15ercury Test "epository* !hared "ject repositor: filename.tsr 1Test $hared "epository* #ser Defined $ibar %ile: filename .%bs* Test &atch Runner %ile: filename .mtb*QTP Reco'er !cenarion %ile: filename .6rs

    *QTP Test !cripts %ile( filename.mts

    What are two tpes of automation in QTP ?

    There are 2 types of automation

    * "ecordin or eneratin the script and playin back usin "epository* nother one is #escripti%e method.

    )an we do more than capture * paback in QTP ?

    7es we can do. That is scriptin we can write scriptwhich is more effecti%e

    What is Descripti'e programming ?

    )ith out mentionin the description in &b8ect repository( we can directly mention the description in Test script is known asdescripti%e prorammin

    What is "bject repositor ?

    &b8ect repository in 6tp is like a storae place where it stores the properties of all the ob8ects when we reocrd the script anlater when we execute the script QTP checks that the ob8ects in the application match the ob8ects in the ob8ect repositoryand executes it( if both the ob8ects matches the test will pass( if it cannot identify the ob8ect or there is a mismatch the scripwill fail.

    &b8ect repository is same as 9,I map in winrunner where we ha%e to make the tool capture the properties of ob8ect whereas in QTP ob8ect repository automatically does that for us.

    What are tpes of "bject repositor +"R,?

    &" are of two types

    http://www.chetanasforum.com/index.php?showtopic=8312http://www.chetanasforum.com/index.php?showtopic=8312http://www.chetanasforum.com/index.php?showtopic=8312http://www.chetanasforum.com/index.php?showtopic=8312
  • 8/9/2019 QTP Faq's 2

    2/29

    * Per'action* $hared

    Tell about Per-action repositor modes

    In this( for each action a seperate ob8ect repository file is created. $o ob8ect in ction is different from the same ob8ect ction2This mode is most useful( when the ob8ect does not chane fre6uently and a few actions are associated with the test. If theob8ect chanes in the application( then we need to chane each of the ob8ect repositor.

    Tell about !hared object repositor modes

    In this( common ob8ect repository file can be used for muliple actions and multile tests. $o &b8ect is action is same forction2( because all the ob8ects are sa%ed at one place. ere if the ob8ect chanes( then we need to update a sinle ob8ecrepository file.

    What are the d'antage / Disad'antge Per-action repositor ?

    d'antage

    * s you record operations on ob8ects in your application( QuickTest automatically stores the information about those ob8ecin the appropriate action ob8ect repository.* )hen you sa%e your test( all of the action ob8ect repositories are automatically sa%ed with the test as part of each action

    within the test. The action ob8ect repository is not accessible as a separate f ile 1as is the shared ob8ect repository.

    Disad'antages

    * 5odifyin the test ob8ect properties( %alues( or names in one ob8ect repository does not affect the information stored for tsame test ob8ect in another ob8ect repository or in other tests ' Time +onsumin* If you add ob8ects to one of the split actions( the new ob8ects are added only to the correspondin action ob8ect repository

    What are the d'antage / Disad'antge !hared object repositor ?

    d'antage

    * &nly one instance of the ob8ect in the repository so reduce the repetitions

    * one time chane to the ob8ect properties would brin chane in e%ery script usin the ob8ect

    Disad'antge

    * +omplexity increase as ob8ects of all the action are in the same repository

    What is )heck points ?

    checkpoint %erifies that expected information is displayed in an pplication while the test is runnin. +heckpoints are useto compare actual and expected results.

    0ow man )heck points are there in QTP ?

    They are ; types of checkpoints

    * 9,I +heck point* 3itmap +heckpoint* #atabase+heckpoint* Test +heckpoint

    What is the use of )heck points ?

    The +heck points is useful to et the point in time from where to bein the reco%ery in case of failure.

    )an we change the name of the )heck points ?

    http://www.chetanasforum.com/index.php?showtopic=8312http://www.chetanasforum.com/index.php?showtopic=8312http://www.chetanasforum.com/index.php?showtopic=8312
  • 8/9/2019 QTP Faq's 2

    3/29

    No( QTP is do not allow to chane the name of +heck point( because these class names are internally built. 3ut in %ersion18ust released it is possible to cahane not in pre%ious %ersions

    What is Transaction ?

    Transaction is a loical unit of work that comprises one or more $Q= statementsexecuted by a sinle user. or It is a rouof statements between two commits

    What is use of !tep 1enerator ?

    $tep 9enerator is used to insert a statement1function ro method of a particular ob8ect which is a%ailable in the &b8ect"epository

    What is !ource )ontrol ?

    The practice of trackin chanes made to code is called $ource +ontrol.!amiliar $ource control Tools are +>$( >$$( +lear+ase etc

    What is &atch testing ?

    9roup of tests executin se6uentially one by one is called 3atch Testin. ?%ery test 3atch consists of mutiple dependenttest cases. In those batches e%ery end state is base state to next case. Test batch is also known as Test suit or Test belt.

    9enerally Test enineers are executin test prorams as a batches because @?nd state of one test is base state to [email protected] result of one $cript failure or pass ( fails or passes the whole batch test.

    What will ou when "bject is not indentifed b the "bect Repositor ?

    ,se $mart identifcation.

    What is !mart identifcation ?

    $mart Identification is used by QTP( whene%er it is unable to identify any ob8ect durin run time. )hile identifyin an ob8ectQTP tries to match the mandatory properties first( if it couldnAt find the ob8ect( then it adds assisti%e properties one by one t

    identify the ob8ect correctly. This operation is done by smart identifier and it is displayed in the results section alon with onwarnin messae. ItAs enerally used to identify )eb elements only.

    What is 2n'oirement 'ariable ?

    ?n%oirement %ariable is %ariable which is lobal throuh the testin.

    What is the tpesof 2n'oirement 'ariable ?

    There are B types of en%ironmental %ariables* ,ser'#efined Internal* ,ser'#efined ?xternal* 3uilt'In

    What are 2xception in QTP ?

    The four exceptions are* Pop exception* &b8ect state* Test run error* pplication crash

    )an We use Test Director with QTP ?

    7es. )e cant use Test #irector C.2 with QTP 4.2. 3ecause QTP 4.2 supports Q+ 1Quality +enter

    http://www.chetanasforum.com/index.php?showtopic=8312http://www.chetanasforum.com/index.php?showtopic=8312http://www.chetanasforum.com/index.php?showtopic=8312
  • 8/9/2019 QTP Faq's 2

    4/29

    )e can use QTP 4.2 with Test director 4./.

    What are ction ?

    There are B types of ctions a%ailable in QTP.* Non'reusable* "eusable* ?xternal ctions

    What is %ramework ?

    framework is nothin but a folder structure . It contains all the components that are usin in utomation rchitecture. ercomponents means &b8ect "epository( =ibrary(=os( Test #ata( $cript( "esult etc

    What is )ompiled modules ?

    In 6tp the compiled modules are called library files .

    What is utomation %ramework ?

    utomation frame work is nothin but a set of rules defined for de%eloppin and oranisin the test scripts orIt is a process to de%elop the automation scripts and reduce maintenance. This framework completely depends on theapplication( types of testin and tools that you are usin. Its hard to pro%ide eneralised framework for all applications:

    3n how man was we can Parameteri4e our test ?

    we can parameteri-e our tests in ; ways.* Test or component parameter* #ata Table parameter* ?n%ironmental %ariable parameter* "andom number parameter

    What are tes of Table ?

    Types of tables are* run time data table

    * desin time data table

    Whats the QTP?

    QTP is 5ercury Interacti%e !unctional Testin Tool.

    Whats the basic concept of QTP?

    QTP is based on two concept'

    "ecordin Playback

    Which scripting language used by QTP?QTP usin >3 scriptin.

    How many types of recording facility are available in QTP?QTP pro%ides three types of recordin methods'

    +ontext "ecordin 1Normal

    nalo "ecordin

  • 8/9/2019 QTP Faq's 2

    5/29

  • 8/9/2019 QTP Faq's 2

    6/29

    Which keword used for run the test script?

    !G

    Which keword used for stop the recording?

    !;

    Which keword used for nalog Recording?

    +trlH$hiftH!;

    Which keword used for $ow $e'el Recording?

    +trlH$hiftH!B

    Which keword used for switch between Tree 6iew and 2xpert 6iew?

    +trlHTab

    7ote:

    QTP records each steps you perform and enerates a test tree and test script.

    QTP records in normal recordin mode.

    If you are creatin a test on web ob8ect( you can record your test on one browser and run it on another browser.

    nalo "ecordin and =ow =e%el "ecordin re6uire more disk sapce than normal recordin mode.

    What5s the Transaction?

    7ou can measure how lon it takes to run a section of your test by definin transactions.

    Where ou can 'iew the results of the checkpoint?

    7ou can %iew the results of the checkpoints in the Test "esult )indow.

    7ote(

    If you want to retrie%e the return %alue of a checkpoint 1a boolean %alue that indicates whether the checkpoint passed orfailed you must add parentheses around the checkpoint arument in the statement in the ?xpert >iew.

    What5s the !tandard )heckpoint?

    $tandard +heckpoints checks the property %alue of an ob8ect in your application or web pae.

    Which en'ironment are supported b !tandard )heckpoint?

    $tandard +heckpoint are supported for all add'in en%ironments.

    What5s the 3mage )heckpoint?

    Imae +heckpoint check the %alue of an imae in your application or web pae.

  • 8/9/2019 QTP Faq's 2

    7/29

    Which en'ironments are supported b 3mage )heckpoint?

    Imae +heckpoint are supported only )eb en%ironment.

    What5s the &itmap )heckpoint?

    3itmap +heckpoint checks the bitmap imaes in your web pae or application.

    Which en'iornment are supported b &itmap )heckpoints?

    3itmap checkpoints are supported all add'in en%ironment.

    What5s the Table )heckpoints?

    Table +heckpoint checks the information with in a table.

    Which en'ironments are supported b Table )heckpoint?

    Table +heckpoints are supported only cti%eF en%ironment.

    What5s the Text )heckpoint?

    Text +heckpoint checks that a test strin is displayed in the appropriate place in your application or on web pae.

    Which en'ironment are supported b Test )heckpoint?

    Text +heckpoint are supported all add'in en%ironments

    ow is it possible find position of F and 7 coordinates on desktop screenJ

    If you want to find F and 7 position of a particular ob8ect of the application under test relati%e to the screen(then usin &b8e$P7 tool (you 8ust click on that particular ob8ect in the screen and find the F and 7 position from the Test &b8ect or "untime&b8ect property list.

    #ata Table

    Two Types of data tables

    9lobal data sheet: ccessible to all the actions=ocal data sheet: ccessible to the associated action only

    ,sae:

    #ataTable1@+olumn Name@(dt9lobal$heet for 9lobal data sheet#ataTable1@+olumn Name@(dt=ocal$heet for =ocal data sheet

    If we chane any thin in the #ata Table at "un'Time the data is chaned only in the run'time data table. The run'time dattable is accessible only throuh then test result. The run'time data table can also be exported usin #ataTable.?xport or#ataTable.?xport$heet

    ow can i sa%e the chanes to my #ataTable in the test itselfJ

    )ell QTP does not allow anythin for sa%in the run time chanes to the actual data sheet. The only work around is to shathe spreadsheet and then access it usin the ?xcel +&5 piAs.

    ow can i check if a parameter exists in #ataTable or notJ

  • 8/9/2019 QTP Faq's 2

    8/29

    The best way would be to use the below code:

    code:''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    on error resume next%alK#ataTable1@ParamName@(dt9lobal$heetif err.numberL / then AParameter does not existelseAParameter existsend if

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    ow can i make some rows colored in the data tableJ

    )ell you canAt do it normally but you can use ?xcel +&5 PIAs do the same. 3elow code will explain some expects of ?xce+&5 PIs

    $5"T Identification

    $mart Identification is nothin but an alorithm used by QTP when it is not able to reconi-e one of the ob8ect. %eryeneric example as per the QTP manual would be( photoraph of a 4 year old irl and boy and QTP records identificatioproperties of that irl when she was 4( now when both are / years old then QTP would not be able to reconi-e the irl.

    3ut there is somethin that is still the same( that is there is only one irl in the photoraph. $o it kind of PI 1Prorammedintellience not I.

    )hen should i use $5"T IdentificationJ

    $omethin that people donAt think about too much. 3ut the thin is that you should disable $I while creatin your test case$o that you are able to reconi-e the ob8ects that are dynamic or inconsistent in their properties. )hen the script has beencreated( the $I should be enabled( so that the script does not fail in case of small chanes. 3ut the de%eloper of the scriptshould always check for the test results to %erify if the $I feature was used to identify a ob8ect or not. $ometimes $I needs be disabled for particular ob8ects in the &"( this is ad%isable when you use $etT&Property to chane any of the T&properties of an ob8ect and especially ordinal identifiers like index( location and creationtime.

    #escripti%e Prorammin

    #escripti%e prorammin is nothin but a techni6ue usin which operations can be performed on the ,T ob8ect which arenot present in the &". !or more details refer to http:DDbondofus.tripod.comDQTPD#PMinMQTP.doc 1riht click and use sa%eas...

    "eco%ery $cenarios

    )hat is a "eco%ery $cenarioJ

    "eco%ery scenario i%es you an option to take some action for reco%erin from a fatal error in the test. The error couldrane in from occasional to typical errors. &ccasional error would be like @&ut of paper@ popup error while printinsomethin and typical errors would be like @ob8ect is disabled@ or @ob8ect not found@. test case ha%e more then onescenario associated with it and also ha%e the priority or order in which it should be checked.

    )hat does a "eco%ery $cenario consists ofJ

    Trier: Trier is nothin but the cause for initiatin the reco%ery scenario. It could be any popup window( any test error(particular state of an ob8ect or any application error.

    ction: ction defines what needs to be done if scenario has been triered. It can consist of a mouseDkeyboard e%ent(close application( call a reco%ery function defined in library file or restart windows. 7ou can ha%e a series of all the specifieactions.Post'reco%ery operation: 3asically defined what need to be done after the reco%ery action has been taken. It could be torepeat the step( mo%e to next step etc....

    )hen to use a "eco%ery $cenario and when to us on error resume nextJ

    http://bondofus.tripod.com/QTP/DP_in_QTP.dochttp://bondofus.tripod.com/QTP/DP_in_QTP.doc
  • 8/9/2019 QTP Faq's 2

    9/29

    "eco%ery scenarios are used when you cannot predict at what step the error can occur or when you know that error wonAtoccur in your QTP script but could occur in the world outside QTP( aain the example would be @out of paper@( as this errois caused by printer de%ice dri%er. @&n error resume next@ should be used when you know if an error is expected and dontwant to raise it( you may want to ha%e different actions dependin upon the error that occurred. ,se err.number err.description to et more details about the error.

    =ibrary !iles or >3$cript !ilesow do we associate a library file with a test J

    =ibrary files are files containin normal >3$cript code. The file can contain function( sub procedure( classes etc.... 7ou canalso use executefile function to include a file at run'time also. To associate a library file with your script o to Test'$ettins... and add your library file to resources tab.

    )hen to associate a library file with a test and when to use execute fileJ

    )hen we associate a library file with the test( then all the functions within that library are a%ailable to all the actions presenin the test. 3ut when we use ?xecutefile function to load a library f ile( then the function are a%ailable in the action that calleexecutefile. 3y associated a library to a test we share %ariables across action 1lobal %ariables basically( usin associatioalso makes it possible to execute code as soon as the script runs because while loadin the script on startup QTP executeall the code on the lobal scope. )e can use executefile in a library file associated with the test to load dynamic files andthey will be a%ailable to all the actions in the test.

    Test and "un'time &b8ect)hat is the difference between Test &b8ects and "un Time &b8ects J

    Test ob8ects are basic and eneric ob8ects that QTP reconi-e. "un time ob8ect means the actual ob8ect to which a testob8ect maps.

    +an i chane properties of a test ob8ect7es. 7ou can use $etT&Property to chane the test ob8ect properties. It is recommended that you switch off the $martIdentification for the ob8ect on which you use $etT&Property function.

    +an i chane properties of a run time ob8ectJ

    No 1but 7es also. 7ou can use 9et"&Property1@outerText@ to et the outerText of a ob8ect but there is no function like$et"&Property to chane this property. 3ut you can use )eb?lement1.ob8ect.outerTextK@$omethin@ to chane theproperty.

    ction !unctions

    )hat is the difference between an ction and a functionJ

    ction is a thin specific to QTP while functions are a eneric thin which is a feature of >3 $criptin. ction can ha%e aob8ect repository associated with it while a function canAt. function is 8ust lines of code with someDnone parameters and asinle return %alue while an action can ha%e more than one output parameters.

    )here to use function or actionJ

    )ell answer depends on the scenario. If you want to use the &" feature then you ha%e to o for ction only. If thefunctionality is not about any automation script i.e. a function like ettin a strin between to specific characters( now this isomethin not specific to QTP and can be done on pure >3 $cript( so this should be done in a function and not an action.+ode specific to QTP can also be put into an function usin #P. #ecision of usin functionDaction depends on what any onwould be comfortable usin in a i%en situation.

    +heckpoint &utput %alue)hat is checkpointJ

  • 8/9/2019 QTP Faq's 2

    10/29

    +heckpoint is basically a point in the test which %alidates for truthfulness of a specific thins in the ,T. There are differentypes of checkpoints dependin on the type of data that needs to be tested in the ,T. It can be text( imaeDbitmap(attributes( F5= etc....

    )hatAs the difference between a checkpoint and output %alueJ

    +heckpoint only checks for the specific attribute of an ob8ect in ,T while &utput %alue can output those attributes %alue toa column in data table.

    ow can i check if a checkpoint passes or notJ

    3ecause QTP uses >3$cript as its scriptin lanuae you ha%e a lot of reference code and sources out there to resol%eissues with. +ase in point( if you want to write a function to compare files there are numerous >3$cript examples 1here an%ia 9oole. If you want to make a call to the )indows $ystem #==As you can et code snippets from 5$#N 1>3$+riptlanuae refence and the )$ lanuae reference and other sources 1aain %ia a 9oole search. If you want to 6uery aF5= file for data there is both 5$#N and 9oole searches that can be done 1look for FPath and #&5 references. If youwant to et information from the "eistry there is a ton of code snippets %ia 9oole to help you fiure it out.

    ?%en then if you do searches for >3 and >3 code snippets you will find them. Eust ot to con%ert them to >3$cript1stripped down %ersion of >3 >3.

    9et out of the Tree >iew D Oeyword >iew. ,se the ?xpert >iew to de%elop your scripts with. The only time to really use theother %iew is for creatin +heckPoints and rabbin ob8ect information when you really need to.

    !inally( reali-e that because QTP is >3$cript and automation is really de%elopment work you will be @prorammin@( and itdoes take some effort and work to become ood at it. #onAt et frustrated with thins. nd be sure to do a $earch first hereand at 9oole before askin 6uestions that are %ery %ery basic and can be answered with a little bit of effort on your part.

    5ercury Interacti%e( )in"unner( and QuickTest ProIntroductionThis document was created because of the ma8or amount of confusion out there about 5ercuryAs intentions with )in"unnand QuickTest Pro. There ha%e been a lot of 6uestions about whether scripts would ha%e to be con%erted( thrown away( orbe reusable. I talked with 5ercury o%er the span of a couple conference calls to et thins cleared up. The content and

    direction of the this document comes from 6uestions that were offered by Q!orums users and 6uestions that I had for myown knowlede.This thread should not be replied to( please reference it in other threads. Thanks. I will update this thread as needed( withinformation confirmed by 5ercury.

    !rom what I ha%e athered from 6uestions that IA%e been asked and the statements that IAm hearin( I think *most* ofe%eryoneAs fears about this new dynamic can be summed up with what 5ercury has been sayin all alon:

    )in"unner and its support are not oin away.

    Now( the Ahow will thins be handled in the futureA and Awill )" do this and will QTP do thatA issues are oin to take somediscussion. $o( here we o.

    @&k( I ot QTP and IA%e ot an app that IAm testin with it. )hat about my )" stuffJ $hould I 8ust throw those scripts outJ@No( no( no. ain( I say( @No.@ QTP is oin to 1if not already ha%e the ability to launch )" and ha%e your scripts run.7ouAre not oin to lose all the scripts( etc. that youA%e built. 7ouA%e had your )" scripts call other )" scripts before... itAsoin to be the same concept. nd whatAs comin in the @near future@ is a centrali-ed results set. )here you run your)"DQTP scripts and they call QTPD)" scripts and your reported results at the end of your test run are all in one place.

    $o an en%ironment that has been usin )" and need a .N?T solution would build .N?T app scripts in QTP and:

    a%e your )" scripts call your QTPD.Net tests

    "un your QTPD.Net scripts and call your )" scripts as needed.5ercury understands that with some /(/// )" customers( thereAs an inordinate amount of architectures( frameworks(

  • 8/9/2019 QTP Faq's 2

    11/29

    harnesses... thereAs no way to come up with one catch'all that will @con%ert@ )" stuff to QTP stuff. $o the idea is to reuse)" stuff %ia the QTPD)" Interation.=et me reiterate this aain( so there is no confusion:

    )IN",NN?" N# )IN",NN?" $,PP&"T "? N&T 9?TTIN9 P$?# &,T.

    )in"unner will be able to call QuickTest Pro scripts.

    QuickTest Pro will be able to call )in"unner scripts.

    )hat one cannot do( the other will.

    =icensinTo re%iew( there are two ways to licenses a product: node'locked and floatin. Node'locked refers to assinin the app toone machine floatin allows a license to be shared between machines at any i%en point in time 12 floatin licenses allowthe app to be accessible from an entire labAs worth of P+As but can only ha%e 2 instances runnin at any i%en point in time

    3efore I continue( I need to state that I cannot tell you exact pricin that 5I has set up for the licenses( howe%er( I *can* i%you an idea of what costs more one way than the other.

    That said( weA%e ot:)" Node'=ocked)" !loatinQTP Node'=ocked

    QTP !loatin&!T Node'=ocked&!T !loatin

    &!TJ )hatAs thatJ That is the new @&ptane !unctional Testin@ license 1N&T?: This is a workin name for the license( itmay chane. It is )" and QTP with the interation. IAll et to that later....

    If youAre usin )" and now need the ability to test in an en%ironment not supported by )"( you ha%e B options:

    ,prade )" to QTP. 7ou =&$? )in"unner here( tradin it in for QTP. If you donAt ha%e a whole lot in%ested into)in"unner yet( and you donAt need to test in en%ironments exclusi%e to )"( this miht be a %iable option for you. If youha%e thousands of )in"unner scripts( this probably is not the way to o.

    dd QTP. 9i%en that there will be 1is an interation for )" and QTP( addin a couple QTP licenses may be an option.

    5o%e to the &ptane !unctional Testin license. 7ou can either purchase these outriht or uprade your )" license to an&!T license. ,pradin a )" license to an &!T license sounds a lot like addin QTP( rihtJ $ure does. 3ut itll costs lessItAs >?"7 I5P&"TNT to consider your node'locked %s. floatin schema here. I canAt tell you which way to o. 7ou need tolook at your lab en%ironment( and how many licenses of which you really need( but there are some ca%eats to this:

    node'locked &!T license allows you to ha%e both )" and QTP installed on &N? 5+IN?( and a )"DQTP script cancall a QTPD)" script( on the one license.

    floatin &!T license allows you to ha%e &N? IN$TN+? of )" or QTP acti%e( accessible from 5,=TIP=? 5+IN?$.That means if you are in a floatin license schema you +NN&T >? &N? PP +== T? &T?"A$ $+"IPT$ )IT&N=7 &N? !=&TIN9 &!T =I+?N$?. Those in smaller companies need to take this into consideration.3i confusion: The oriinal information about &ptane !unctional Testin licenses did not i%e the impression that there waa node locked option. It looked like there was oin to be @out of reach@ costs to et into )"DQTP. 5ercury is oin back tothe wordin on how the !T licensin schema is bein described and make it less confusin.There will e%en be a +# install for &!T: It will ha%e both )" and QTP installs on the disk. ?xpect to see this at the end ofQ2 with the QTP R. release.

    )"DQTP +omparisons and @In The !uture@)in"unner C.R is scheduled to come out next 6uarter. )in"unner 4./ is scheduled to be released at the end of the year.3eyond that( yes( there will be enhancements made to )in"unner.)in"unner 3oth QuickTest Pro

  • 8/9/2019 QTP Faq's 2

    12/29

    +lassic +ommon ?merin+ustom +D$Power3uilder!orte#elphi+entura$tinray$mallTalk?"PD+"5

    3aanPeople$oft )indows$iebel G( R 9,I +lients&racle 9,I !orms)eb'"elated ?n%ironmentsI?( Netscape( &=E#O( Ea%a !oundation +lasses( )T$ymantec >isual +afS

    cti%eF +ontrols?"PD+"5

    &racle: Einitiator( i( N+E# ?dwards )eb +lient

    +ustom +lient $er%er

    )indows+HHD+>isual 3asic&peratin $ystems

    )in

  • 8/9/2019 QTP Faq's 2

    13/29

    +ommon: en%ironments supported by both )in"unner and QuickTest. Includes I?( Netscape( )indows( Ea%a( >isual 3asiand terminal emulator 1Ureen screenV applications.

    ?merin: en%ironments supported by only QuickTest. Includes .Net newer ?"PD+"5 en%ironments such as my$P and$iebel C.x and 5acromedia !lash.5ercury Interacti%e is committed to pro%idin onoin support for )in"unner in all +lassic and +ommon en%ironments( anis committed to ensurin that QuickTest works in all +ommon and ?merin en%ironments. This means that( for instance(when a new %ersion of Power3uilder is released and ains market acceptance( 5ercury Interacti%e will build support for thnew %ersion of Power3uilder into )in"unner. )hen a new %ersion of I? is released( 5ercury Interacti%e will build supportfor it in both )in"unner and QuickTest. s new %ersions of .Net( $P( and $iebel are released( 5ercury Interacti%e willsupport those en%ironments in QuickTest. This le%el of en%ironment support will continue throuh 2//B and beyond. 5ercuInteracti%es oal is to ensure that customers can continue to reali-e the benefits of usin our functional testin solutions intheir existin en%ironments as these en%ironments e%ol%e.QuickTest Pro and......Test#irectorThe interation of QTP and T# is the same as it is for )" and T#. Test $ets( Test "uns( etc. are able to be created usinQuickTest Pro scripts. $ince T# can handle both )" and QTP scripts in a Test $et( both can be in the same run.

    ...5$ ?xcelEust like you can create data tables usin 5icrosoft ?xcel for )" scripts( you can do the same thin for the QTP data dri%escripts that you will create.

    ...#atabasesccordin to 5ercury( database testin %ia QTP is e6ual or better than %ia )". QTP has:

    ?nhanced + database import enine.

    Pro%ides same #3 %erification wi-ard that is in )"

    &pen extension of >3 enine 1+&5 based replay enine: can make direct calls to + db at the ob8ect le%el+onclusionThere was a 6uestion about when to use one o%er the other outside of a scriptin preference. QTP has reusable actions(icon based script( acti%e screen( and an interated data table. It is really up to the indi%idual and how your en%ironment isoin to et set up. Those that are new to automated testin may find QTP easier in the lon run. ccordin to 5ercury(many of the Ulessons learnedV from )in"unner ha%e been incorporated into QTP.

    There are certain en%ironments that )in"unner wonAt be able to o. This may be a matter of business decision or simply)in"unnerAs architecture. The impression that I ot from my con%ersations with 5ercury was that they ha%e no intention oabandonin )in"unner or its users. 5ercury is respondin to market conditions where there is a reater focus on QuickTePro. $o you may ha%e to use a QuickTest Pro solution( but you wonAt be forced into phasin out )in"unner.

    )hich way should you oJ ain( that depends on your en%ironment. If you ha%e been usin )in"unner and now you findyou need QuickTest Pro( there are a number of uprade paths a%ailable. 7ouAll be able to trade in licenses( add( con%ert(etc.

    ow to locate and click on an item in a web table

    . 9et the number of columns and rows in the table. This can be done usin the "ow+ount and +olumn+ount methods.2. =oop throuh the cells in the table.

    B. 9et the data %alue from the cell. This can be done usin the 9et+ell#ata method.

    Note:If the %alue you are lookin for is not a text %alue( you may need to use an alternate method.

    ;. If the data is the %alue you want( use the +hildItem method to et a reference to the ob8ect you wish to click.G. ,se the +lick method to click on the data item.

    ?xample:A 9et the row countrowcount K 3rowser1@[email protected]@Pae@.)ebTable1@The )eb #irectory@."ow+ount

  • 8/9/2019 QTP Faq's 2

    14/29

    A =oop throuh the cells in the tablefor r K to rowcountA 9et the column count of row rcolcount K 3rowser1@[email protected]@Pae@.)ebTable1@The )eb #irectory@.+olumn+ount1rA =oop throuh columns of row rfor c K to colcountA 9et the %alue from the cell.%alue K 3rowser1@[email protected]@Pae@.)ebTable1@The )eb #[email protected]+ell#ata1r( c

    A +heck if the %alue is the one you want.if %alue K @7ahoo@ thenA The ob8ect was found. +lick on it.3rowser1@[email protected]@Pae@.)ebTable1@The )eb #irectory@.+hildItem1r( c( @=ink@( /.+lickA $et a fla to exit the loops.found K trueA ?xit the column loop.exit forend ifnextA +heck whether item was found.if found K true thenA Item was found( exit the row loop.exit for

    end ifnext

    )ebTable1description.+hildItem1"ow( +olumn( T&M+lass( Index

    "ow "ow number where the cell is located. The first row in the table is numbered .+olumn +olumn number where the cell is located. The first column in the table is numbered .T&M+lass &b8ect type.Index Index of the ob8ect of type T&M+lass in the cell. It is used to specify the desired element when there is more then onob8ect of type T&M+lass in the cell. The f irst ob8ect has an index of /.

    The third parameter for the +hildItem method is the 5ic+lass of the ob8ect you want in the cell. The last parameter is theindex number of the ob8ect. If your cells only ha%e one ob8ect in them( then use / for this parameter.

    To determine what the 5ic+lass of the ob8ect is( do the followin.. 9o to Tools ' 9,I $py.2. +lick on the hand button.B. +lick on the ob8ect in the table cell.;. The 5ic+lass is listed as the @+lass Name@ property.

    QTP has a lobal ob8ect synchroni-ation timeout. )hen a step attempts to interact with an ob8ect that is not a%ailable whethe application is still processin( QTP will wait for either the ob8ect to become a%ailable or for the ob8ect synchroni-ationtimeout to occur.W If one process takes considerably loner than others( the lobal synchroni-ation timeout may not be lon enouh for the

    process to complete. nd in this case( the next step miht fail. To i%e these loner processes enouh time to complete( wadd a synchroni-ation point to extend the time QTP will wait before mo%in on to the next step.W )ait times often occur before an ob8ect becomes a%ailable for the next step.W $ynchroni-ation points instruct QuickTest to pause until an ob8ect property achie%es a specified %alue.W The easiest way to add a synchroni-ation point is while recordin.W lways add the synchroni-ation point immediately after the step to be synchroni-ed.W !rom the QTP menu bar( choose IN$?"T X $T?P X $7N+"&NIYTI&N P&INT.W $tep timeout %alues add to the lobal timeout %alues.W )hen the synchroni-ation timeout is set for a step( this %alue is added to the lobaltimeout %alue.W QTP has a default timeout between test steps of 2//// milliseconds 12/ seconds.W 5ay not wait for the full timeout to arri%e.

  • 8/9/2019 QTP Faq's 2

    15/29

    0ow to find a row in a WebTable using the text of a specifie

    ,se the 9et"ow)ith+ellText method

    The 9et"ow)ith+ellText method returns the number of the first row found that contains a cell with the specified text.

    ob8ect.9et"ow)ith+ellText 1Text( Z+olumn[( Z$tart!rom"ow[

    ob8ect test ob8ect of type )ebTable

    Text The text strin for which to search+olumn 1&ptional The column number where the cell is located. The %alue can either be the column name or index. Index%alues bein with .$tart!rom"ow 1&ptional The number of the row in which to start the search. The first row in the table is numbered .

    ?xample :row K 3rowser1@5ercury [email protected]@$earch "esults@.)ebTable1@&[email protected]"ow)ith+ellText1@Price@( 2( 2$et =ink K 3rowser1@5ercury [email protected]@$earch "esults@.)ebTable1@&utbound!lihts@.+hildItem1row( 2( @=ink@( /=ink.+lick

    ?xample 2:A ,sin the attached sample T5= pae

    row K 3rowser1@[email protected]@Pae@.)ebTable1@!irst [email protected]"ow)ith+ellText1@$econd item@( 2$et chkbx K 3rowser

    0ow to check if an 2xcel file is read-onl before writing to

    +heck the "ead&nly ?xcel property

    QuickTest Professional does not ha%e a built'in method that will allow you to check whether the external ?xcel file is alreadopen and bein edited. owe%er( you can use the ?xcel &b8ect 5odel methods and properties to check if the f ile is read'only.

    "efer to @5icrosoft ?xcel 2/// >isual 3asic for pplications ob8ect model@ for a complete listin of ?xcel methods andproperties that can be used within a QuickTest Professional 1QTP script. 7ou can use these ?xcel ob8ect methods within aQTP script to create workbooks( create new sheets( input data( etc.

    The followin example will loop until the file is not read'only 1opened by another script. )ithin the loop( the file is openedand then the "ead&nly property is retrie%ed. If the file is read'only( the file is closed and released. The script will wait a shotime 1currently G// milliseconds( then attempt to open the file aain.

    ?xample:$et ?xcel&b8 K +reate&b8ect1@?xcel.pplication@

    excelreadonly K TrueA =oop while the file is read'only#o )hile excelreadonly$et New)orkbook K ?xcel&b8.)orkbooks.&pen1@+:temptest.xls@

    excelreadonly K New)ork3ook."ead&nly

    If excelreadonly Then A If readonlyA +lose the file and release the obect?xcel&b8.pplication.Quit$et New)orkbook K Nothinwait /( G//?nd If=oop

    msbox @?xcel file is not bein used...@msbox @#oin somethin....@

    http://www.software-automation.org/forum/viewtopic.php?t=354&start=0&postdays=0&postorder=asc&highlight=http://www.software-automation.org/forum/viewtopic.php?t=355&start=0&postdays=0&postorder=asc&highlight=http://www.software-automation.org/forum/viewtopic.php?t=354&start=0&postdays=0&postorder=asc&highlight=http://www.software-automation.org/forum/viewtopic.php?t=355&start=0&postdays=0&postorder=asc&highlight=
  • 8/9/2019 QTP Faq's 2

    16/29

    A "elease the excel ob8ects?xcel&b8.pplication.Quit$et New)orkbook K Nothin$et ?xcel&b8 K Nothin

    #isplay bold text in the results:

    !ormat the "eport?%ent messae text usin the T5= Lfont ta

    !ormattin( such as colored text( can be sent to the results usin the T5= Lfont ta.

    ?xample :A The followin line of code sends red and blue text to the results:"eporter."eport?%ent /( @Lfont$ome ?%entLDfont@ (@Lfont3lue Text LDfont@

    ?xample 2:A The followin line of code sends some bolded text to the results:"eporter."eport?%ent /( @&olded?%ent@ (@This text is bolded@

    3s it possible to get properties from a 'irtual object

    Test ob8ect properties for %irutal ob8ects can be captured

    7ou can use the 9etT&Property method to retrie%e the %alue of properties that are used in the ob8ect repository. Thereis no way to retrie%e other properties from a %irtual ob8ect.

    >irtual+heck3ox.9etT&Property1Property

    Property Property whose %alue is retrie%ed from the ob8ect description.

    The 9etT&Property function returns the %alue of a specified property for a test ob8ect. The %alue is taken from the ob8erepository.

    Note:7ou can use the 9etT&Property method to retrie%e the %alues of only those properties that are included in the testob8ect description. $pecifyin a property that is not included in the test ob8ectAs description results in a warnin status fthe step and the test.

    ?xample:msbox )indow1@!liht "eser%ation@.)indow1@&pen&rder@.>irtual+heck3ox1@[email protected]&Property1@name@

    Insertin a Pae ob8ect checkpoint

    . )hile recordin( o to Insert ' +heckpoint ' $tandard +heckpoint.2. ,sin the pointin hand( click on an ob8ect on the )eb application.

    B. In the @&b8ect $election@ dialo( select the Pae ob8ect.;. +lick L&O.G. $elect the desired Pae +heckpoint Properties.R. +lick L&O.

    Resol'ing en'ironmental conflicts (

    ?n%ironmental issues are typically caused by a conflict with a runnin process or with an unexpected %ersion of a #==&ne or more of these suestions( should help you determine what is causin the en%ironmental issue.

    . Talk with your de%elopers or technicians to determine if there are any processes( utilities( or ser%ices that are installeor runnin on the problem machines but not on the workin machines. This could be different %irus scanners( network

    http://www.software-automation.org/forum/viewtopic.php?t=359&start=0&postdays=0&postorder=asc&highlight=http://www.software-automation.org/forum/viewtopic.php?t=359&start=0&postdays=0&postorder=asc&highlight=
  • 8/9/2019 QTP Faq's 2

    17/29

    connection utilities( mouse dri%ers( etc. It is possible that one of those processes( utilities( or ser%ices is causin aconflict.

    2. +heck the processes that are runnin on the problem machine.

    $tart QuickTest Professional( and perform the actions needed to reproduce the problem.&pen the Task 5anaer 1$tart ' "un ' taskmr.exe.Note the processes which are runnin. Try to identify what the processes are for.To determine if there is a conflict with a runnin process( end the processes one at a time. 7ou can narrow down the lissomewhat by comparin the processes with those from a workin machine. &nce you ha%e a list of unknown or differeprocesses( kill one of the processes and restart QuickTest Professional.$ee if the problem reproduces. If the issue continues( repeat the steps with the next process in the Task 5anaer.If you find a process that seems to be causin the problem( try killin that process only. "estart or relo into yourmachine. &pen the Task 5anaer and kill that process. $tart QuickTest Professional and see if you can recreate theproblem. If you are unable to recreate the problem( then you most likely ha%e found the conflictin process. Note( theissue can be caused by a few processes runnin toether 1these processes are usually for the same utility orapplication thouh.

    B. +heck the %ersion of the #==s that are in use. 7ou will need to check the #==s that are directly in use and( possiblythe #==s that are re6uired by those #==s. ,se a utility that will i%e you a list of #==s bein used by an application.&nce you ha%e this list( check the %ersion of these #==s with the %ersions from a workin machine.

    If you find %ersions that do not match( copy the #==s from the workin machine to the problem machine. 5ake sure yo

    back up the #==s before replacin them. If the %ersions of those #==s match( check the %ersions of the #==s uponwhich those #==s rely. 7ou can use 5icrosoftAs #ependency )alker utility to determine which #==s are used by anoth#==.

    0ow to select a Web)heck&ox using its adjacent text

    ,se the custom )eb+heck3ox3y=abel function 1Internet ?xplorer only

    Note:This function is not part of QuickTest Professional. It is not uaranteed to work and is not supported by 5ercury+ustomer $upport. 7ou are responsible for any and all modifications that may be re6uired.

    )eb+heck3ox3y=abel1 parent( ar

    parent The Pae ob8ect containin the checkbox item you want to selectar The text to locate

    This function uses the #&5 ob8ect( so it will only work on Internet ?xplorer.

    !unction )eb+heck3ox3y=abel1 parent( ar

    A +reate a description for the )eb+heck3ox ob8ect$et desc K #escription.+reate1desc1@type@.>alue K @checkbox@desc1@html ta@.>alue K @INP,T@

    A "etrie%e all )eb+heck3ox ob8ects on the pae$et cbcol K parent.+hild&b8ects1desc

    cnt K cbcol.countA =oop throuh the )eb+heck3ox ob8ects!or ob8 K / to cnt'A 9et the text next to the checkboxtext K cbcol1ob8.ob8ect.etd8acentText1@afterend@A Is this the text weAre lookin forJIf ar K Trim1text Thencbcol1ob8.$et @&N@

    http://www.software-automation.org/forum/viewtopic.php?t=362&start=0&postdays=0&postorder=asc&highlight=http://www.software-automation.org/forum/viewtopic.php?t=362&start=0&postdays=0&postorder=asc&highlight=
  • 8/9/2019 QTP Faq's 2

    18/29

    ?xit !or?nd IfNext

    ?nd !unction

    "eister,ser!unc @Pae@( @)eb+heck3ox3y=abel@( @)eb+heck3ox3y=abel

    ,se the >3$cript !ilter function

    $earch %alue in an array:

    The !ilter function returns a -ero'based array containin a subset of a strin array based on a specified filter criteria.

    !ilter1Input$trins( >alueZ( IncludeZ( +ompare[[

    Input$trins 1"e6uired &ne'dimensional array of strins to be searched.>alue 1"e6uired $trin to search for.Include 1&ptional 3oolean %alue indicatin whether to return substrins that include or exclude >alue. If Include is Tru!ilter returns the subset of the array that contains >alue as a substrin. If Include is !alse( !ilter returns the subset ofthe array that does not contain >alue as a substrin.+ompare 1&ptional Numeric %alue indicatin the kind of strin comparison to use. $ee $ettins section for %alues.

    The +ompare arument can ha%e the followin %alues:%b3inary+ompare / Perform a binary comparison.%bText+ompare Perform a textual comparison.

    If no matches of >alue are found within Input$trins( !ilter returns an empty array 1the ,bound will be '. n erroroccurs if Input$trins is Null or is not a one'dimensional array.

    The array returned by the !ilter function contains only enouh elements to contain the number of matched items.

    ?xample :"e#im myrray1

    myrray1/ K @5on 2@myrray1 K @Tues B@myrray12 K@)ed ;@myrray1B K@Thurs G@myrray1; K@!ri R@myrray1G K@$at C@myrray1R K@$un 4@myrray1C K @5on

  • 8/9/2019 QTP Faq's 2

    19/29

    msbox @Item not found in array@else!or i K / to ,bound1myIndexmsbox myIndex1iNext?nd If

    Note:The !ilter function does not return the positions where the elements are found in the input array. If the indexes areneeded( you should loop throuh the elements in the array one by one.

    ?xample:!or i K / to ,bound1myrrayIf instr1myrray1i( @5on@ Thenmsbox i @ @ myrray1i?nd If

    ow to synchroni-e on the mouse cursor

    )hen the userAs application is busy processin data or performin a task( the mouse cursor chanes to indicate thebusy state 1the cursor chanes to an hourlass.Is there a way to synchroni-e on the mouse cursor and make QuickTest Professional wait until the mouse is not busybefore proceedin to the next statementJ

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    $olution: ,se the custom function Is3usy

    Note:This function is not part of QuickTest Professional. It is not uaranteed to work and is not supported by 5ercury+ustomer $upport. 7ou are responsible for any and all modifications that may be re6uired.

    Is3usy1 hwnd

    hwnd The handle of the application window or ob8ect

    ,se the customi-ed Is3usy function located in the attached .-ip file. Is3usy checks to see if the mouse cursor iscurrently set to the busy icon. If it is( it returns a positi%e non'-ero %alue( otherwise it returns /.

    . ,n-ip the attached file to a temporary location.2. +opy the +$ync#== function to your desired location.B. In the script( declare the Is3usy function.

    ?xample:extern.#eclare mic,=on(@Is3usy@(@+:temp+$ync.dll@(@Is3usy@(mic,=on

    ;. +apture the handle of the application window.

    ?xample:hwndK)indow1@5y)[email protected]"&Property1@hwnd@

    G. +all the Is3usy function as needed.

    ?xample:A )ait until the cursor is no loner an hourlass)hile extern.Is3usy1hwndwait )end

    The Is3usy script demonstrates how to use the function.

  • 8/9/2019 QTP Faq's 2

    20/29

    The source directory contains the source code for the .#== as well as the source code for the >isual 3asic applicationthat the Is3usy script tests.

    Note:7ou can also synchroni-e on the cursor type 1state. !or information on how do et the cursor state( please refer toProblem I# ;;G4B ' ow to determine the state of the mouse cursor.

    ?xample:A 9et the handle of the application window or ob8ecthwnd K )indow1@[email protected]"&Property1@hwnd@A 9et the cursor type 1state%al K et+ursorType 1hwnd

    A =oop while the cursor is the specified type#o )hile 1%al K @I#+MI3?5@ A I'beam cursorwait %al K et+ursorType 1hwnd=oop

    The abo%e example waits while the mouse cursor is in the I'3eam cursor state.

    ,se the custom !$3rowser"estore and !$3rowser5inimi-e functions

    Note:These functions are not part of QuickTest Professional. They are not uaranteed to work and are not supported by5ercury +ustomer $upport. 7ou are responsible for any and all modifications that may be re6uired.

    To restore a full screen browser window to its oriinal si-e( use the custom !$3rowser"estore function.

    !$3rowser"estore1ob8

    ob8 The 3rowser ob8ect

    A\#escription "estores a full screen browser to oriinal si-e

    A\#ocumentation "estore the full screen browser to its oriinal si-e!unction !$3rowser"estore1ob8A Press the "estore toolbar button.ob8.)inToolbar1@nati%eclass:KToolbar)indowB2@( @window id:K/@.Press @"estore@?nd !unction

    "eister,ser!unc @3rowser@( @!$3rowser"estore@( @!$3rowser"estore@

    ?xample:3rowser1@7ahoo]@.!ull$creenwait 3rowser1@7ahoo]@.!$3rowser"estore

    To minimi-e a full screen browser( use the custom !$3rowser5inimi-e function.

    !$3rowser5inimi-e1ob8

    ob8 The 3rowser ob8ect

    A\#escription 5inimi-es a full screen browserA\#ocumentation 5inimi-e the full screen browser!unction !$3rowser5inimi-e1ob8A Press the 5inimi-e toolbar button.

  • 8/9/2019 QTP Faq's 2

    21/29

    ob8.)inToolbar1@nati%eclass:KToolbar)indowB2@( @window id:K/@.Press @5inimi-e@?nd !unction

    "eister,ser!unc @3rowser@( @!$3rowser5inimi-e@( @!$3rowser5inimi-e@

    Note:To restore a minimi-ed full screen browser( you need to use the )indow ob8ect "estore method. The!$3rowser"estore method will not work.

    ?xample:3rowser1@7ahoo]@.!ull$creen3rowser1@7ahoo]@.!$3rowser5inimi-eA "estore the minimi-ed browser)indow1@5icrosoft Internet ?xplorer@."estore

    To record the restore method:. $tart recordin.2. 9o to Test ' =ow'=e%el "ecordin. This step starts =ow'=e%el recordin.B. +lick on the browser in the system task bar.;. 9o to Test ' =ow'=e%el "ecordin. This step stops =ow'=e%el recordin. lternati%ely( you can stop recordincompletely

    ,se the custom !$3rowser"estore and !$3rowser5inimi-e functions

    Note:These functions are not part of QuickTest Professional. They are not uaranteed to work and are not supported by5ercury +ustomer $upport. 7ou are responsible for any and all modifications that may be re6uired.

    To restore a full screen browser window to its oriinal si-e( use the custom !$3rowser"estore function.

    !$3rowser"estore1ob8

    ob8 The 3rowser ob8ect

    A\#escription "estores a full screen browser to oriinal si-e

    A\#ocumentation "estore the full screen browser to its oriinal si-e!unction !$3rowser"estore1ob8A Press the "estore toolbar button.ob8.)inToolbar1@nati%eclass:KToolbar)indowB2@( @window id:K/@.Press @"estore@?nd !unction

    "eister,ser!unc @3rowser@( @!$3rowser"estore@( @!$3rowser"estore@

    ?xample:3rowser1@7ahoo]@.!ull$creenwait 3rowser1@7ahoo]@.!$3rowser"estore

    To minimi-e a full screen browser( use the custom !$3rowser5inimi-e function.

    !$3rowser5inimi-e1ob8

    ob8 The 3rowser ob8ect

    A\#escription 5inimi-es a full screen browserA\#ocumentation 5inimi-e the full screen browser!unction !$3rowser5inimi-e1ob8A Press the 5inimi-e toolbar button.ob8.)inToolbar1@nati%eclass:KToolbar)indowB2@( @window id:K/@.Press @5inimi-e@

  • 8/9/2019 QTP Faq's 2

    22/29

    ?nd !unction

    "eister,ser!unc @3rowser@( @!$3rowser5inimi-e@( @!$3rowser5inimi-e@

    Note:To restore a minimi-ed full screen browser( you need to use the )indow ob8ect "estore method. The!$3rowser"estore method will not work.

    ?xample:3rowser1@7ahoo]@.!ull$creen3rowser1@7ahoo]@.!$3rowser5inimi-eA "estore the minimi-ed browser)indow1@5icrosoft Internet ?xplorer@."estore

    To record the restore method:. $tart recordin.2. 9o to Test ' =ow'=e%el "ecordin. This step starts =ow'=e%el recordin.B. +lick on the browser in the system task bar.;. 9o to Test ' =ow'=e%el "ecordin. This step stops =ow'=e%el recordin. lternati%ely( you can stop recordincompletely.

    Posted: $un &ct G( 2//R B:;/ am Post sub8ect: ow to sinle step throuh a script

    ,se the #ebu menu @$tep Into@ and @$tep &%er@ options 1! and !/

    $inle steppin throuh a script can be done with the @$tep &%er@ and @$tep Into@ actions under the #ebu menu. 7ou canalso use the ! hotkey for $tep Into( or the !/ hotkey for $tep &%er.

    The $tep Into option runs the current line of the script. If the current line calls a method( the method is displayed in the %iewbut is not performed. The $tep &%er option runs the current line of the script. )hen the current line calls a method( themethod is performed in its entirety( but is not displayed in the %iew.

    To launch and sinle step throuh a script:. &pen the desired test.2. Press ! to start the script run.B. $elect the test results location( and click L&O.

    ;. Press ! twice to enae the test flow.G. Press ! or !/ to enter the first action.R. Press ! or !/ repeatedly to sinle step the script.

    To sinle step throuh a specified section of a script:. &pen the desired script.2. Place a breakpoint on the step you wish to start from.B. "iht'click on that step( and select @"un from step.@;. $elect the test results location( and click L&O.G. Press ! or !/ to step throuh the script as needed.

    ?xample:msbox @one@

    msbox @two@msbox @three@msbox @four@msbox @fi%e@msbox @six@

    In the abo%e script( you want to execute 1one at a time lines B( ;( and G. Place a breakpoint on line B 1this is the msbox@three@ line. Then riht'click on line B and select "un from $tep. The "un dialo will appear. $elect the location for the tesresults. This will either be a @new run results folder@ or the @temporary run results folder@. +lick L&O to close the dialo. Thyellow execution arrow will appear next to the third line. t this point( because there is a breakpoint on line B( QuickTestProfessional will be in run mode( but will not be executin the test. Press ! or !/. messae box will appear with thetext @three@. +lose the messae box. The execution arrow will mo%e down to line ;. Press ! or !/ aain. messae bo

    http://www.software-automation.org/forum/posting.php?mode=quote&p=437http://www.software-automation.org/forum/viewtopic.php?p=437#437
  • 8/9/2019 QTP Faq's 2

    23/29

    with the text @four@ will appear. +lose the messae box. The execution arrow will mo%e to line G. Press ! or !/ aain. messae box with the text @fi%e@ will appear. +lose the messae box. $ince there are additional lines still in the script(QuickTest Professional will still be in run mode 1thouh it will be idle. +lick the $top button to end test execution.

    Posted: $un &ct G( 2//R B:;/ am Post sub8ect: ow to sinle step throuh a script

    ,se the #ebu menu @$tep Into@ and @$tep &%er@ options 1! and !/

    $inle steppin throuh a script can be done with the @$tep &%er@ and @$tep Into@ actions under the #ebu menu. 7ou canalso use the ! hotkey for $tep Into( or the !/ hotkey for $tep &%er.

    The $tep Into option runs the current line of the script. If the current line calls a method( the method is displayed in the %iewbut is not performed. The $tep &%er option runs the current line of the script. )hen the current line calls a method( themethod is performed in its entirety( but is not displayed in the %iew.

    To launch and sinle step throuh a script:. &pen the desired test.2. Press ! to start the script run.B. $elect the test results location( and click L&O.;. Press ! twice to enae the test flow.

    G. Press ! or !/ to enter the first action.R. Press ! or !/ repeatedly to sinle step the script.

    To sinle step throuh a specified section of a script:. &pen the desired script.2. Place a breakpoint on the step you wish to start from.B. "iht'click on that step( and select @"un from step.@;. $elect the test results location( and click L&O.G. Press ! or !/ to step throuh the script as needed.

    ?xample:msbox @one@msbox @two@

    msbox @three@msbox @four@msbox @fi%e@msbox @six@

    In the abo%e script( you want to execute 1one at a time lines B( ;( and G. Place a breakpoint on line B 1this is the msbox@three@ line. Then riht'click on line B and select "un from $tep. The "un dialo will appear. $elect the location for the tesresults. This will either be a @new run results folder@ or the @temporary run results folder@. +lick L&O to close the dialo. Thyellow execution arrow will appear next to the third line. t this point( because there is a breakpoint on line B( QuickTestProfessional will be in run mode( but will not be executin the test. Press ! or !/. messae box will appear with thetext @three@. +lose the messae box. The execution arrow will mo%e down to line ;. Press ! or !/ aain. messae bowith the text @four@ will appear. +lose the messae box. The execution arrow will mo%e to line G. Press ! or !/ aain. messae box with the text @fi%e@ will appear. +lose the messae box. $ince there are additional lines still in the script(QuickTest Professional will still be in run mode 1thouh it will be idle. +lick the $top button to end test execution.

    re checkpoints a%ailable in 3usiness +omponents

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    $olution: $inle property checks are a%ailable with 3usiness +omponents

    5ultiple property checkpoints are not a%ailable to Oeyword'dri%en 3usiness +omponents. +heckpoints are notrecommended for use within $cripted +omponents. To check ob8ect properties in a component( use a sinle propertycheck.

    http://www.software-automation.org/forum/posting.php?mode=quote&p=437http://www.software-automation.org/forum/viewtopic.php?p=437#437
  • 8/9/2019 QTP Faq's 2

    24/29

    The 3usiness +omponents ha%e some built'in methods you can use to %erify the %alues or other properties of the%arious controls in your application.

    To %erify whether a specified ob8ect is enabled:

    >erify?nable1ob8ob8 The test ob8ect

    To %erify the %alue of a specified ob8ect:>erify>alue1ob8( ?xpected>alueob8 The test ob8ect?xpected>alue The expected %alue to be compared and %erified durin the test run. The format of the expected %aluedepends on the type of test ob8ect.

    To %erify the %alue of a specified property:>erifyProperty1ob8( PropertyName( ?xpected>alueob8 The test ob8ectPropertyName The property name to check?xpected>alue The expected %alue of the property

    Note:QuickTest Professional passes the test ob8ects to the functions automatically( so you do not need to pass a %alue to thfirst parameter when callin these functions.

    )hen workin with 3usiness Process Testin 4.2. %ia Test#irector for Quality +enter( there is no default list of a%ailabob8ect properties from which a sinle property checkpoint can be created. The property must be entered manually. nenhancement re6uest for a default list of properties has been submitted.

    7ou can use the QuickTest Professional &b8ect $py or refer to the QuickTest Professional &b8ect 5odel "eferencedescription for a list of properties you can reference. !or example( if your control is a standard windows button( refer tothe &b8ect 5odel "eference ' $tandard )indows ' )in3utton &b8ect ' Properties ' )in3utton IdentificationProperties.

    ?ach of the functions will return True if the expected condition is met.

    Parameteri-in components

    . +reate the component.2. $elect the Parameters tab. dd the inputDoutput parameters as needed.

    +lick LNew.?nter a descripti%e name in the Parameter name( and click L&O. To make the input and output parameters easier toidentify( you may want to add @Min@ or @Mout@ to the end of the parameter name. The new parameter will appear in therele%ant list.$elect the >alue Type for the parameter.!or input parameters( enter the default %alue that should be used. The default %alue must correspond to the selected%alue type.In the #escription column( add a description for the parameter.B. $elect the utomation tab. 1If you are usin 3PT 4.x select the $teps tab.;. In the Oeyword >iew( select the step to be parameteri-ed.

    G. +lick on the @+onfiure the %alue@ button in the >alue cell. The @>alue +onfiuration &ptions@ dialo will appear.R. $elect the @Parameter@ radio button and @+omponent parameter@ in the combobox.C. $elect the desired component parameter in the Name combobox.4. "epeat steps ; throuh C for each input parameter.

  • 8/9/2019 QTP Faq's 2

    25/29

    Data Table

    Two Types of data tables

    9lobal data sheet: ccessible to all the actions

    =ocal data sheet: ccessible to the associated action only

    #sage(

    #ataTable1@+olumn Name@(dt9lobal$heet for 9lobal data sheet

    #ataTable1@+olumn Name@(dt=ocal$heet for =ocal data sheet

    If we chane any thin in the #ata Table at "un'Time the data is chaned only in the run'time data table. The run'time dattable is accessible only throuh then test result. The run'time data table can also be exported usin #ataTable.?xport or#ataTable.?xport$heet

    0ow can i sa'e the changes to m DataTable in the test itself?

    )ell QTP does not allow anythin for sa%in the run time chanes to the actual data sheet. The only work around

    to share the

    spreadsheet and then access it usin the ?xcel +&5 piAs.

    0ow can i check if a parameter exists in DataTable or not?

    The best way would be to use the below code:

    code:

    on error resume next%alK#ataTable1@ParamName@(dt9lobal$heetif err.numberL / then AParameter does not existelse AParameter existsend if

    0ow can i make some rows colored in the data table?

    )ell you canAt do it normally but you can use ?xcel +&5 PIAs do the same. 3elow code will explain some expect

    of ?xcel +&5 PIs

    code:

    $et xlppK+reateob8ect1@?xcel.pplication@set xl)ork3ookKxlpp.workbooks.addset xl)ork$heetKxl)orkbook.worksheet.add

  • 8/9/2019 QTP Faq's 2

    26/29

    xl)ork$heet."ane1@:3/@.interior.colorindex K B; A+hane the color of the cellsxl)ork$heet."ane1@:/@.%alueK@text@ A)ill set %alues of all / rows to @text@xl)ork$heet.+ells1(.%alueK@Text@ A)ill set the %alue of first row and first col

    rows+ountKxl)ork$heet.?%aluate1@+&,NT1:@ A)ill count the of rows which ha%e non blank %alue in thecolumn cols+ountKxl)ork$heet.?%aluate1@+&,NT1:@ A)ill count the of non blank columns in st row

    xl)orkbook.$a%es @+:Test.xls@xl)ork3ook.+lose$et xl)ork$heetKNothin$et xl)ork3ookKNothinset xlppKNothin

    !8RT 3dentification

    $mart Identification is nothin but an alorithm used by QTP when it is not able to reconi-e one of the ob8ect. %eryeneric example as per the QTP manual would be( photoraph of a 4 year old irl and boy and QTP records identificatioproperties of that irl when she was 4( now when both are / years old then QTP would not be able to reconi-e the irl.3ut there is somethin that is still the same( that is there is only one irl in the photoraph. $o it kind of PI 1Prorammedintellience not I.

    When should i use !8RT 3dentification?

    $omethin that people donAt think about too much. 3ut the thin is that you should disable $I while creatin your

    test cases. $o that you are able to reconi-e the ob8ects that are dynamic or inconsistent in their properties. )henthe script has been created( the $I should be enabled( so that the script does not fail in case of small chanes. 3uthe de%eloper of the script should always check for the test results to %erify if the $I feature was used to identify aob8ect or not. $ometimes $I needs to be disabled for particular ob8ects in the &"( this is ad%isable when you use$etT&Property to chane any of the T& properties of an ob8ect and especially ordinal identifiers like index( locatioand creationtime.

    Descripti'e Programming

    #escripti%e prorammin is nothin but a techni6ue usin which operations can be performed on the ,T ob8ect

    which are not present in the &". !or more details refer to http:DDbondofus.tripod.comDQTPD#PMinMQTP.doc 1rihtclick and use sa%e as...

    Reco'er !cenarios

    What is a Reco'er !cenario?

    "eco%ery scenario i%es you an option to take some action for reco%erin from a fatal error in the test. The error

    could rane in from occasional to typical errors. &ccasional error would be like @&ut of paper@ popup error whileprintin somethin and typical errors would be like @ob8ect is disabled@ or @ob8ect not found@. test case ha%e more

    then one scenario associated with it and also ha%e the priority or order in which it should be checked.

    What does a Reco'er !cenario consists of?

    Trier: Trier is nothin but the cause for initiatin the reco%ery scenario. It could be any popup window( any tes

    error( particular state of an ob8ect or any application error. ction: ction defines what needs to be done if scenario has been triered. It can consist of a mouseDkeyboard

    e%ent( close application( call a reco%ery function defined in library file or restart windows. 7ou can ha%e a series ofall the specified actions.

    Post'reco%ery operation: 3asically defined what need to be done after the reco%ery action has been taken. It could

    be to repeat the step( mo%e to next step etc....

    http://bondofus.tripod.com/QTP/DP_in_QTP.dochttp://bondofus.tripod.com/QTP/DP_in_QTP.doc
  • 8/9/2019 QTP Faq's 2

    27/29

    When to use a Reco'er !cenario and when to us on error resume next?

    "eco%ery scenarios are used when you cannot predict at what step the error can occur or when you know that err

    wonAt occur in your QTP script but could occur in the world outside QTP( aain the example would be @out of paperas this error is caused by printer de%ice dri%er. @&n error resume next@ should be used when you know if an error iexpected and dont want to raise it( you may want to ha%e different actions dependin upon the error that occurred,se err.number err.description to et more details about the error.

    $ibrar %iles or 6&!cript %iles

    0ow do we associate a librar file with a test ?

    =ibrary files are files containin normal >3$cript code. The file can contain function( sub procedure( classes etc....

    7ou can also use execute file function to include a file at run'time also. To associate a library file with your script oto Test'$ettins... and add your library file to resources tab.

    When to associate a librar file with a test and when to use execute file?

    )hen we associate a library file with the test( then all the functions within that library are a%ailable to all the action

    present in the test. 3ut when we use ?xecutefile function to load a library file( then the function are a%ailable in theaction that called executefile. 3y associated a library to a test we share %ariables across action 1lobal %ariablesbasically( usin association also makes it possible to execute code as soon as the script runs because whileloadin the script on startup QTP executes all the code on the lobal scope. )e can use executefile in a library fileassociated with the test to load dynamic files and they will be a%ailable to all the actions in the test.

    dd-ins

    Test and Run-time "bjectWhat is the difference between Test "bjects and Run Time "bjects ?

    Test ob8ects are basic and eneric ob8ects that QTP reconi-e. "un time ob8ect means the actual ob8ect to which a

    test ob8ect maps.

    )an i change properties of a test object

    7es. 7ou can use $etT&Property to chane the test ob8ect properties. It is recommended that you switch off the$mart Identification for the ob8ect on which you use $etT&Property function.

    )an i change properties of a run time object?

    No 1but 7es also. 7ou can use 9et"&Property1@outerText@ to et the outerText of a ob8ect but there is no function

    like $et"&Property to chane this property. 3ut you can use )eb?lement1.ob8ect.outerTextK@$omethin@ tochane the property.

    ction / %unctionsWhat is the difference between an ction and a function?

    ction is a thin specific to QTP while functions are a eneric thin which is a feature of >3 $criptin. ction can

    ha%e a ob8ect repository associated with it while a function canAt. function is 8ust lines of code with someDnoneparameters and a sinle return %alue while an action can ha%e more than one output parameters.

    Where to use function or action?

    )ell answer depends on the scenario. If you want to use the &" feature then you ha%e to o for ction only. If the

    functionality is not about any automation script i.e. a function like ettin a strin between to specific characters(now this is somethin not specific to QTP and can be done on pure >3 $cript( so this should be done in a function

  • 8/9/2019 QTP Faq's 2

    28/29

    and not an action. +ode specific to QTP can also be put into an function usin #P. #ecision of usin functionDactiodepends on what any one would be comfortable usin in a i%en situation.

    )heckpoint / "utput 'alueWhat is checkpoint?

    +heckpoint is basically a point in the test which %alidates for truthfulness of a specific thins in the ,T. There are

    different types of checkpoints dependin on the type of data that needs to be tested in the ,T. It can be text(imaeDbitmap( attributes( F5= etc....

    What9s the difference between a checkpoint and output 'alue?

    +heckpoint only checks for the specific attribute of an ob8ect in ,T while &utput %alue can output those attributes

    %alue to a column in data table.

    0ow can i check if a checkpoint passes or not?

    code:

    chkMPass!ail K 3rowser1....Pae1....)eb?dit1....+heck 1+heckpoint1@+heck@if chkMPass!ail then 5s3ox @+heck Point passed@else 5s3ox @+heck Point failed@end if

    8 test fails due to checkpoint failing: )an i 'alidate a checkpoint without m test failing due to checpoint failure?

    code:

    "eporter.!ilter K rf#isablell A#isables all the reportin stuffchkMPass!ail K 3rowser1....Pae1....)eb?dit1....+heck 1+heckpoint1@+heck@"eporter.!ilter K rf?nablell A?nable all the reportin stuffif chkMPass!ail then 5s3ox @+heck Point passed@else 5s3ox @+heck Point failed@end if

    2n'ironment0ow can i import en'ironment from a file on disk

    ?n%ironment.=oad!rom!ile @+:?n%.xml@

    0ow can i check if a en'ironment 'ariable exist or not?

    )hen we use ?n%ironment1@Param@.%alue then QTP expects the en%ironment %ariable to be already defined. 3u

    when we use ?n%ironment.%alue1@Param@ then QTP will create a new internal en%ironment %ariable if it does notexists already. $o to be sure that %ariable exist in the en%ironment try usin ?n%ironment1@Param@.%alue.

  • 8/9/2019 QTP Faq's 2

    29/29

    0ow to connect to a database?

    code:

    +onst ad&pen$tatic K B+onst ad=ock&ptimistic K B+onst ad,se+lient K B

    $et ob8+onnection K +reate&b8ect1@#.+onnection@$et ob8"ecordset K +reate&b8ect1@#."ecordset@ob8+onnection.&pen @#"I>?"K_5icrosoft + for &racle`,I#KL,I#P)#KLP)#@ob8"ecordset.+ursor=ocation K ad,se+lientob8"ecordset.+ursorType K adopenstaticob8"ecordset.=ockType K adlockoptimistic&b8"ecordset.$ourceK@select field(field2 from testTable@&b8"ecordset.cti%e+onnectionK&b8+onnection&b8"ecordset.&pen AThis will execute your QueryIf &b8"ecordset.recordcount/ then

    !ield K &b8"ecordset1@!ield@.>alue!ield2 K &b8"ecordset1@!ield2@.>alue

    ?nd if

    0ow to create dialog box with option in QTP ?

    res K msbox 1@Is it your first run 17esDNo J @( %b7esNo(@!irst run Indicator@If res K R Then A R K 7es C K Nosome code ....end if

    #im $ample$ample K Input3ox 1@+heckin@( RG( @Input3ox $ample@