The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:




Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> HP / Mercury LoadRunner

Pages: 1 | 2 | >> (show all)
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
SWales - TruClient Knowlege Base
      #664213 - 03/14/11 01:22 PM

I have been doing considerable amount of work using LoadRunner 11 and TruClient. There doesn't seem to be much technical information on TruClient out there yet, so I thought I would start a thread focusing on how to's and any useful information pertaining to TruClient.

I only ask that we keep this thread limited to how to's and useful information. Discussions should happen on other threads and their links referenced here. That will help keep this thread as more of an index to the other discussions.

Hopefully the admin will make this a 'sticky' so it's easy to find.

Edited by swales (03/14/11 01:31 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #664214 - 03/14/11 01:23 PM Attachment (1119 downloads)

How to do a random Think Time in TruClient (see attachment).

This has been submitted to HP as a KB Article.

Also to do a 'Global' think time:

Use the "Inter-step interval" run-time setting to specify the time (in ms) between steps. This setting will be used for ALL the steps in the script.


Edited by swales (03/14/11 01:37 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #664215 - 03/14/11 01:24 PM Attachment (1323 downloads)

How to dynamically select a link (based on a parameter value). (see attachment)

This has been submitted to HP as a KB Article

Edited by swales (03/14/11 01:37 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #664218 - 03/14/11 01:30 PM

Documentation
--------------
AJAX TruClient Tips and Tricks
c:\Program Files\HP\LoadRunner\help\LoadRunner11.00_AjaxTruClient_TipsTricks.pdf

YouTube Videos
----------------
HP TruClient Technology

HP LoadRunner 11.00 - Ajax TruClient Protocol
* Same video as what included in LR11 product

Edited by swales (03/14/11 01:55 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #664219 - 03/14/11 01:35 PM

Q. How do I set LoadRunner to save snapshots and Where are they stored?
A. LoadRunner can be set to save snapshots for recording and replay.
To setup snapshot capture when replaying do the following:
1. In VuGen - Vuser - Runtime Settings - Other Settings - Snapshots generation - Replay snapshots generation - Always

Snapshots will be saved in the following locations:
* If using TruClient, snapshots are stored in different locations based on where the script is executed from.
1. If executed from FireFox (Develop script) the snapshot is located at:
Script Directory/results/interactive

2. If executed from VuGen the snapshot is located at:
Script Directory/results/load


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #664221 - 03/14/11 01:56 PM

Q. How do I parameterize a script?
A. Follow this process to parameterize a script. (Movies-TruClient.wmv)
1. Create the parameter in VuGen (Vuser - Parameter List) - same process as any other protocol
2. Click Develop Script to Launch Firefox
3. Expand the toolbox - Miscellaneous - Evaluate JavaScript
4. Drag and Drop the Evaluate JS above the statement where you need the parameter
5. Add the following code to the Code: tag
example: transferAmount=LR.getParam("Amount")
6. Go to the step you want to parameterize and replace the Value: (10) with the parameter name (transferAmount)

or
1. Go to the step you want to parameterize and replace the Value: (10) with the code:
example: LR.getParam("Amount")


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #664222 - 03/14/11 02:00 PM

Q. How do I put in an output message so it shows up in the Controller?
A. LR.log function is used for logging.
window.alert() will print to a popup dialog box.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #664223 - 03/14/11 02:00 PM

Q. How do I randomly pick an item on the screen?
A. If the item is a List. (Ajax TruClient Tips and Tricks.pdf)
1. Set the Ordinal argument to 0. TruClient will automatically select a random option from the list.

If the item is a bunch of links.
1. You can use JavaScript (see Ajax TruClient Tips and Tricks.pdf)
ex. A page returned with multiple links with the same "title" attribute we want the script to randomly click a link.

var my_results = document.querySelectorAll('a[title="SearchResult"]');
my_results[Math.floor(Math.random() * my_results.length)];


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #673605 - 06/02/11 12:25 PM

Want to improve scalability of your load generators?

The runtime setting Interstep Interval has a default of 500ms. Try increasing this to 1000ms or 2000ms.

Yes it is true you will be 'pausing' longer between each step, however it seems to give your CPU a little breathing room to multitask a little better. We found around a 15 to 25% improvement in scalability depending on the app.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #673611 - 06/02/11 12:48 PM

TruClient scalability tests

I recently completed a series of tests comparing our 'old' load test generators with our 'new' prototype generator.

Old Generators
Intel Pentium DuoCore 3.0ghz
2gb Ram
Windows XP

Prototype Generator
Amd Phenom II B95 3.0ghz (Quad core)
16GB Ram
Windows 7-64bit


My test applications were limited to between 8 users and 25 users on the old generators (based on the application) before CPU was maxed out. Memory would also be an issue at around 25 users since most apps seem to take at least 60mb of ram per user (your app may vary) and our old generators only had 2gb..

The new generators were able to handle 8x (8 times) more users before CPU was maxed out. Memory should be able to handle over 200 users... so most likely CPU will be bottleneck before that. The scalability was very close between applications... so based on this hardware you could expect the 8x scalability improvement.

Good news is you can get back/close to the 100+ users on a generator.

I suspect the new Intel Sandy Bridge processors (i5-2500k/i7-2600k) will scale much higher than the AMD Phenom II.. and hope to acquire one for comparison results in the future.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Chid
Active Member


Reged: 06/27/06
Posts: 812
Loc: USA
Re: SWales - TruClient Knowlege Base [Re: swales]
      #678793 - 07/14/11 08:37 AM

Posted by Shane on LR Google Groups

------------------------------------------

TruClient uses Mozilla to only record the script. Note that I said record, as during playback there *is no browser*.

Mozilla is simply a vehicle for the recording engine as it allows LoadRunner full access to the DOM, where Internet Explorer (8 and below) do not. So if the application *works* in Firefox, even if it is not your corporate
standard, TruClient would be the better choice here.

There is no browser used in any LoadRunner performance tests. Only a lightweight agent that communicates with the AUT in the same manner as a client application would.

--------------------
Chid | My LR Profile | LoadRunner Reading


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: Chid]
      #678806 - 07/14/11 10:03 AM

Chid/Shane

You are incorrect on how TruClient works. It DOES run a copy of FireFox for each virtual user. This is why it does not scale as well as the old (HTTP/HTML) protocols. It is also why AJAX apps work in TruClient... because it is using a 'real' browser.

The reason HP supports FireFox and not IE right now is because Mozilla allows them to turn off certain features during the load test (such as screen rendering) which reduces memory footprint and improves scalability (albiet slightly). Microsoft is rumored to enable this behavior in IE9... so we could expect to see LoadRunner TruClient support for IE9 possibly in LoadRunner 12.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #679394 - 07/19/11 11:16 AM

Quote:

Q. How do I randomly pick an item on the screen?
A. If the item is a List. (Ajax TruClient Tips and Tricks.pdf)
1. Set the Ordinal argument to 0. TruClient will automatically select a random option from the list.





I have found that with Patch 3 installed you need to also clear the TEXT argument field in order to get TruClient to select a Random Link. If you leave the TEXT there it will select randomly from the text that matches what you have in the TEXT field. So if you have multiple items with the exact same TEXT value, it would randomly select one of them.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #681231 - 08/04/11 11:21 AM

Quote:

TruClient scalability tests

I recently completed a series of tests comparing our 'old' load test generators with our 'new' prototype generator.

Old Generators
Intel Pentium DuoCore 3.0ghz
2gb Ram
Windows XP

Prototype Generator
Amd Phenom II B95 3.0ghz (Quad core)
16GB Ram
Windows 7-64bit


My test applications were limited to between 8 users and 25 users on the old generators (based on the application) before CPU was maxed out. Memory would also be an issue at around 25 users since most apps seem to take at least 60mb of ram per user (your app may vary) and our old generators only had 2gb..

The new generators were able to handle 8x (8 times) more users before CPU was maxed out. Memory should be able to handle over 200 users... so most likely CPU will be bottleneck before that. The scalability was very close between applications... so based on this hardware you could expect the 8x scalability improvement.

Good news is you can get back/close to the 100+ users on a generator.

I suspect the new Intel Sandy Bridge processors (i5-2500k/i7-2600k) will scale much higher than the AMD Phenom II.. and hope to acquire one for comparison results in the future.




I finally received an Intel I5-2400 3.1ghz for testing purposes. It had the same config as the Amd Phenom II B95 3.0ghz as far as Windows version and Ram. Both were HP desktop machines.

In summary the Intel i5-2400 scalability was 10% to 15% better than the AMD for the same application. My test was able to max the CPU to 100% during the ramp up test. At each level of the ramp up the Intel took 10 to 15% less CPU.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Venkat_Sravan
Newbie


Reged: 07/01/11
Posts: 4
Re: SWales - TruClient Knowlege Base [Re: swales]
      #683425 - 08/29/11 04:42 AM

Hi All,

Don't Know if this is the right thread to ask this question.
I have been working on LR 11.0 truclient protocol for our application. I came across a weird problem where in when I run th tests in controller I am unable to see any graphs except for the response time graph. Did any one had this kind of an issue??? Any help here would be really great!!


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #701275 - 03/13/12 03:46 PM

Quote:

How to dynamically select a link (based on a parameter value). (see attachment)

This has been submitted to HP as a KB Article




I have an update for this technique. Originally the problem was that in 'certain' areas of TruClient you were unable to access any of the LR functions... like LR.getParam(). TruClient would throw an error. So in my above example I figured out a workaround by adding an Evaluate JavaScript statement and storing the LR Parameter into a global Java Variable (window.variable). I could then use the java variable in my statement. This made it a two step process. You also had to be careful because your app might clear the window objects between calls.

It appears HP exposes the LR functions throught an ArgContext. So in those statements where TruClient does not like LR.getParam() you now use ArgContext.LR.getParam().

I would like to give credit to Abdul Rahim for documenting this at: http://softwaretesttips.com/2011/04/19/h...-script-editor/

How to extract and manipulate the data contained in an object verification window (java script editor)?
April 19, 2011
Abdul Rahim
Leave a comment
Go to comments
How to extract and manipulate the data contained in an object verification window (java script editor)?

Accessing to the LR API. It is available from the JavaScript ID Method by qualifying the API with ArgsContext

Important Points:JavaScript code running in Evaluate JavaScript steps (or any other step) is executed in a context called ArgsContext.

JavaScript code running in Evaluate JavaScript steps (or any other step) is executed in a context called ArgsContext.
JavaScript code running in JavaScript ID Method is executed in a separate context (upon each call, a new context is created).
When you are using an Evaluate JavaScript step, your code is already executed inside the ArgsContext, so there is no need to qualify it by adding the prefix ArgsContext.
You only need to use the ArgsContext prefix if you are using the JavaScript ID Method and you wish to access something that is defined in the ArgsContext (e.g. the LR API).
For example, in Evaluate JavaScript step you can write LR.log(TEST), but in the JavaScript ID Method you need to write ArgsContext.LR.log(TEST).


Post Extras: Print Post   Remind Me!   Notify Moderator  
tebiet
Newbie


Reged: 02/18/09
Posts: 7
Re: SWales - TruClient Knowlege Base [Re: Venkat_Sravan]
      #709252 - 06/07/12 09:34 AM

You will be able to see other graphs after installing the latest patch.

Post Extras: Print Post   Remind Me!   Notify Moderator  
BooKa
Newbie


Reged: 07/26/12
Posts: 4
Re: SWales - TruClient Knowlege Base [Re: swales]
      #713059 - 07/26/12 05:50 AM

One more trick for LR 11 P03

Load mode replay for Ajax Tru Client protocol fails with error
Activate browser window #2 ** failed runtime error:
Ordinal: The specified value (2) is invalid [MsgId: MERR-203254]
The script replays fine in interactive mode.
This issue is specific to LR/PC 11.03 version (Works fine with LR/PC 11.02).
There is a problem with function Activate tab which doesnt recognise any other tab than the first one.
To fix this issue follow the below steps

1. Open your script and click on develop script.
2. This will launch the Firefox browser.
3. Type at the Firefox browser
about:config
4. Find disable_open_during_load and set it to false.
5. Save the script again (Copy to controller again etc.).

Original post by Abdul Rahim

--------------------
Just because I don't care doesn't mean I don't understand.


Post Extras: Print Post   Remind Me!   Notify Moderator  
BooKa
Newbie


Reged: 07/26/12
Posts: 4
Re: SWales - TruClient Knowlege Base [Re: swales]
      #713060 - 07/26/12 06:09 AM

If you need to turn on Flash in TruClient script:

  • Download NPSWF32.dll
  • Interactive mode: Add it to <LR installation>\bin\firefox\plugins
  • Load mode: Add it to <LR installation>\bin\gecko\plugins


--------------------
Just because I don't care doesn't mean I don't understand.


Post Extras: Print Post   Remind Me!   Notify Moderator  
BooKa
Newbie


Reged: 07/26/12
Posts: 4
Re: SWales - TruClient Knowlege Base [Re: swales]
      #713061 - 07/26/12 06:12 AM

If you need to see FireFox window with actions that your script is executing at this moment in load mode, just add
PaintWindowsInLoad="1" key into default.cfg file (RTS) into [TruClient] section.

--------------------
Just because I don't care doesn't mean I don't understand.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: BooKa]
      #716569 - 09/17/12 12:23 PM

(Duplicate post removed.)

Edited by ptrussell_nc (09/19/12 07:53 AM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: BooKa]
      #716639 - 09/18/12 03:24 PM

Timeout vs. Wait
-----------------

A common issue we run into with TruClient is due to timing
issues in the applications. Often times when you click a Submit button on a form it might take awhile for the application to come back. Normally TruClient waits 20 seconds by default and if the page has not come back it will fail.

One solution I have seen used is to put a WAIT statement in the script. Although this might work, it is not the best solution. The reason is because a WAIT statement will do exactly that it will wait the specified time, whether it needs to or not. If the wait was not long enough the script will still fail. It you set it too long the users are just sitting there doing nothing. This causes your test to not do as much activity as you would want.

A better solution would be to place a VERIFY statement in the script right after the SUBMIT. Basically you VERIFY that something came back on the screen. This has 2 benefits. First the VERIFY is a great way to make sure the app is doing what is should. Next is you can set the Object Timeout and Step Timeout to large values. They will wait a MAXIMUM of these value, but if the screen comes back faster, then the user will continue as soon as it can.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #718335 - 10/18/12 11:05 AM

Q. How do I Capture data (like a web_reg_save_param)?
A. Use the "Visible Text" Property

Set the Step - Action to Get Property
Set the Arguments - Property to "Visible Text"
Set the Variable to the name of the parameter you want (ex. "myproduct") <- note the quotes around the parameter name
Set the Object - ID Method to XPath
Set the XPath to one that is using an object path rather than the original text (ex. Agriculture)


Post Extras: Print Post   Remind Me!   Notify Moderator  
Devendra_Singh
Member


Reged: 09/20/12
Posts: 27
Loc: India
Re: SWales - TruClient Knowlege Base [Re: swales]
      #718477 - 10/21/12 11:05 PM

Very good thread Swales. Appreciate your effort of making things available at one place.

Thanks,

--------------------
Devendra Singh
http://performancetestingcentre.blogspot.com/


Post Extras: Print Post   Remind Me!   Notify Moderator  
xtom
Member


Reged: 01/19/04
Posts: 100
Loc: Germany
Re: SWales - TruClient Knowlege Base [Re: Devendra_Singh]
      #718573 - 10/23/12 01:42 AM

AJAX TruClient - Correlation

The following describes how to do some kind of correlation in AJAX TruClient protocol. The flow in my case is to create a new offer record, take the generated offer number from the screen, search for this number in the search dialog and change the record to be shure that the new record was processed and correlation worked as desired.

Everything needs to be done in Firefox (Develop script)!

Step 1
After recording find the skript step where the offer number is shown on the screen. I think this should be the earliest step where the value appears at the first time.

Step 2
Open the Toolbox and drag the step "Verify" from the "Functions" area after the step located above.

Step 3
The new inserted step displays the value 'Click to choose an object'. Before this is clicked it is necessary to navigate in Firefox to the screen that contains the value that has to be correlated.

Step 4
Click the value 'Click to choose an object' in the new step and touch the value that has to be correlated in Firefox. The area of this value is highlited in green.
The description of the script step changes to something like: '"Visible Text" contains "AP1-197269-01E"'.

Step 5
Expand the new step and open the "Step" area. Substitute the value for "Action" to use "Get Property" instead of "Verify"

Step 6
Open the "Arguments" area. Select the property "Visible Text" and enter the name for the variable. This name needs to be enclosed in double quotation marks. In this example it will be "Angebotsnummer".

Step 7
Open the "Object" area. Select the "ID Method" as "XPath". Then select in the drop down list for "XPath" field the value that does not contain the explicit value. For example i do NOT select this "//span[text()="AP1-197269-01E"]", i select this "/html/body/form/table[2]/tbody/tr[2]/td/table[6]/tbody/tr/td[2]/table/tbody/tr/td[2]/span[2]".

Step 8
To verify if the above configuration is correct, open the Toolbox again and add one more step. Drag the step "Evaluate JavaScript" from the "Miscellaneous" area after the step just created above.

Step 9
Expand the new step and open the "Arguments" area. Enter the command "window.alert(Angebotsnummer)" (without double quotes) in the field "Code".

Step 10
Execute the script to verify the success. The step created above will cause an alert window pop up that displays the value captured from the screen. This should be the same like in the application.

Step 11
Reuse the captured value as input for the search dialog to find the newly created offer number. To do this the according step where the number is used as input needs to be found. In my case the step contained the information 'Type "AP1-197269-01E" in Angebotsnummer textbox' was displayed in the step.

Step 12
Expand the step and open the "Arguments" area. Substitute the existing value "AP1-197269-01E" by the variable name "Angebotsnummer" (without double quotes).

Step 13
Delete the step where the alert pop up was inserted, because it will disturb the script flow.


Restrictions:
I do not know how to correlate values that are not displayed on the screen and i do not know if this is necessary in AJAX TruClient.

Regards
Thomas

--------------------
xtom


Post Extras: Print Post   Remind Me!   Notify Moderator  
Grabelke
Newbie


Reged: 11/09/12
Posts: 2
Re: SWales - TruClient Knowlege Base [Re: BooKa]
      #719671 - 11/12/12 03:13 AM

Hello swales,

thanks a lot for sharing the helpful information about TruClient.

I have a question about how can i get the (dynamic)value of an object.

I am trying to record an Ajax application with the TruClient protocol.
I have several testusers for the login. After the login the fullname of the testuser is displayed in the application. I would like to "find out" (capture) the fullname for each user and it later in the script. How can I do this in TruClient? Should I use "Evaluate JS on Object"? How should the JS look like?

Thanks in advance for your help.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: Grabelke]
      #719688 - 11/12/12 07:41 AM

Grabelke,
See my post about 'Visible Text' above. It does what you are looking for.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #719701 - 11/12/12 11:17 AM

Object Identification... Automatic vs. XPath vs. JavaScript

Most issues involving "Object not Found" errors can be resolved by changing the Object Identification from Automatic to XPath or JavaScript.

As of Patch 3 LoadRunner will generate multiple XPath options. Most often one of these options will contain the TEXT of what you see on the screen and the other will contain the DIV path of the object.

Example - Here are 2 XPath options generated by LoadRunner
//b[text()="Working Account:"]

or

/html/body/form/div[2]/center[1]/table[2]/tbody/tr/td[1]/b

If the text of the object is not expected to change then choose the XPath that is simplest (eg. contains the text). If the text does change between iterations, then choose the other XPath option with the DIV path.

If you need to refine the XPath you will need to use the JavaScript option. LoadRunner will generate an evalXPath() function with the XPath. You can then alter this XPath to refind what is returned.

Also remember to validate your selection by using the Highlight option. See next post on debugging XPaths.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #719702 - 11/12/12 11:37 AM

Debugging XPaths

See previous post on Object Identification. Once you have changed your selection to XPath you need to know how to debug the XPath statements... especially if you are trying to alter the selection.

LoadRunner provides a great feature to help debug XPaths. it is the Highlight button on the Object tab of the statement. Start by navigating to the right page... you can simply run the script until you get to the statement you are debugging. Click Highlight button. LoadRunner will draw a red box around the object it finds that matches the XPath.

Now lets make it interesting. Lets say you have a list of radio buttons on the screen. You recorded clicking on one of the radio buttons, but what you REALLY want to do is randomly choose one of the available radio buttons.

Set the ID Method to JavaScript, then click to Edit the JavaScript. You will see an evalXPath statment such as this:

evalXPath("//table[@id=\"dataTable\"]/tbody/tr[1]/td[1]/input");

If you alter the XPath like this it will select all the radio buttons:

evalXPath("//table[@id=\"dataTable\"]/tbody/tr[1]/td/input");

Notice the last [1] was removed. Since the reference to a specific radio button was removed from the XPath, it looks for all objects matching.

Now here is the cool part. If you click the Highlight button now... LoadRunner will highlight each object that matches. So you will see the red box being drawn around each object. This helps you verify you found all the objects you wanted.

Now to randomly select one of them you can make the following change.

var options = evalXPath("//table[@id=\"dataTable\"]/tbody/tr[1]/td/input)

random(options);

This saves all the objects returned into a variable called options. Then the random() function will select one of them and return it.

I also recommend installing the FireBug add-on. It has some great features to find XPaths. Simply press F12 to activiate FireBug, then right click on an object and choose Inspect. The you can hover over the code to get the XPath... also right-click to Copy XPath.

Hope this helps.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #719703 - 11/12/12 11:49 AM

XPath Contains Clause

I had a situation where the app I was testing had a list of Products on the screen. Some of the Products had RED text and some GREEN text. The test case called for only choosing from the RED Products.

I discovered I could use a Contains clause in my XPath statement to do what I needed.

My original XPath was:
var products = evalXPath("/html/body/form/div/table[2]/tbody/tr[3]/td/div/div/label");

I altered it to:
var products = evalXPath("/html/body/form/div/table[2]/tbody/tr[3]/td/div/div/label[contains(@style,'red')]");

Now only the RED Products were returned in my products variable.

Another similar situation was where the Products were in a folder list that could be expanded or collapsed. I needed to only select from the list that was expanded.

var products = evalXPath("/html/body/form/div/table[2]/tbody/tr[3]/td/div/div[contains{@class,'ajaxtree_open')]");

Without the contains clause the script was selecting Products from all list whether they were expanded or not.

Again I used FireBug to 'see' what what happening in the code when I expanded or collapsed the Product. This helped me discover the class was changing.

Another useful tip? Let me know if you find these useful and I will continue my efforts to post.

Thanks.


Post Extras: Print Post   Remind Me!   Notify Moderator  
swales
Junior Member


Reged: 07/11/02
Posts: 173
Loc: Moline,IL
Re: SWales - TruClient Knowlege Base [Re: swales]
      #719896 - 11/19/12 10:03 AM Attachment (467 downloads)

How to select a random option from a listbox... and optionally skip the first option.

Many times the developers will use the first option in a listbox to provide instructions to the user.. ex.. (Please select option)... well if you randomly pick from the listbox you MIGHT pick this option... which is not really a valid selection the developer intended.

This attached article will describe how to work around this in TruClient.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1 | 2 | >> (show all)



Extra information
0 registered and 35 anonymous users are browsing this forum.

Moderator:  AJ, James Pulley, ptrussell_nc, JimHowell1970 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating: ****
Topic views: 43379

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5