Coded UI Test data driven in UIMap.cs - visual-studio-2010

I have a lot of codeduitest. There are common test step in each test method. For example; this.UImap.navigatetourl(); I have moved it in UIMap.cs. Because I have changed code for navigatetourl().I want to run the same test method for different urls. I can use data driven test in CodedUITest but I want to use data driven test in UIMap.cs. What can I do?
Thanks,

Take your UIMap.NavigateToUrl() method and add a parameter to it for the URL you want to go to. Use that value to set the appropriate *Params property in your UIMap before actually doing the the navigation. (I'm assuming you recorded a navigation action of some kind?)
In your CodedUI test, take the relevant value from your data source and pass it through to the UIMap.NavigateTo() method as the URL parameter value.

Related

How can I add/import/include 'IncludeController' in JSR223/Groovy and use it in current TestPlan?

How can I access/use the specific test fragment file (jmx file) in the project use JSR223/Groovy code and use a specific Sampler?
For example, I have test fragments files [patientApi.jmx, doctorApi.jmx], each of these include fragment contains bunch of HTTP Requests (endpoint) with assertions and etc.:
patientApi.jmx:
{uri}/patientApi/getFirstName
{uri}/patientApi/getLastName
{uri}/patientApi/getDoctors
{uri}/patientApi/blaBla
doctorApi.jmx:
{uri}/doctorApi/getFirstName
{uri}/doctorApi/getLastName
{uri}/doctorApi/getPatients
{uri}/doctorApi/blaBla
So, I would like to know can I import/add/include in my new TestPlan these test fragments and disabled/enabled specific HTTP requests. It will give me the ability to create different test suites.
The only option I can think of is using an Include Controller per API endpoint and naming them according to the endpoint URL.
Once done you can put them under the Switch Controller and choose which one you want to execute by providing the relevant "Switch Value"
The "Switch value" doesn't have to be hard-coded, you can use a JMeter Variable there originating from i.e. CSV Data Set Config

TYPO3 pass controller context to ajax request

I am working on a TYPO3-backend-module. The main "overview"-Action allows to upload a file via ajax upload, which gets processed in one of my controllers.
The corresponding controller-action instantiates a StandaloneView, renders it and writes the rendered content to the response body.
My problem is, that I have no controllerContext set in the generated content, therefore a form, which should trigger a different extbase action, in that rendered content does not work, because the modulename is not set.
Can anybody tell me how I could possibly get/pass the controllerContext, to make it available in the controller action, which is called via ajax ?
Best regards and thanks in advance, Oliver !
The main problem here is that BE modules don't exactly use a standard View implementation - in the default implementation, they wrap around a StandaloneView which by definition has no controller context.
That being said, if you can change the way the View wraps around the StandaloneView, the controller context can be copied by doing:
$view->getRenderingContext()->setControllerContext($parentView->getRenderingContext()->getControllerContext());
Alternatively you may want to copy the entire rendering context rather than just the controller context.
Advise applies to TYPO3v8 only. On 7.6 you will need to copy the Request instead.
For usages outside of MVC context you will need to manually pass the original controller context values such as controller name and module name. That means the values must be part of the link you create and must be read by the receiving code (in whichever way that code's context requires) and then manually assigned to a Request you create and pass to the sub-view. Note that this is only necessary if those MVC context values actually change - if you always call the same action next, you can get the right result by simply hardcoding the desired extension name, module name, controller name and action in the form/link in the template you render from that AJAX controller.

jmeter how to replay recorded unique id from application

I am very new to Jmeter and trying to use it for doing load testing my application.
In my application, every time we click on a template, application will allocate a unique id which to the template...when I recorded the steps using jmeter, a particular unique id was recorded...but when I tried to play the recorded case...it is looking for the same unique id....how do I tell jmeter to get the new id from the application?
Here are the steps
Login as a user,
click on a particular link,
click on a button which will then popup a window asking to select a template,
After selecting a template, my application will create a unique id for that template
It very much depends on whether that template ID is created on the client (i.e. by JavaScript), or on the server (i.e. you can actually record a template ID returned by the server).
If second is your case, then server returns template ID in the response to template selection, so you can use one of the post-processors - a supporting element invoked after the parent request; it usually extracts data from the response and saves it as a variable(s). In your case you'd extract template ID and save it as variable. Later samplers can use the variable in format ${your_name} instead of the recorded hard-coded string. So in that case your plan could look like this:
Which post-processor to use and how to use it depends on the response you are receiving form the server, so cannot be more specific here.
If the first option is your case (JavaScript on the client generates template ID; and your recording only contains usage of said ID), then you can simulate what JavaScript is doing by generating a similar ID using one of the JMeter script-related features: it could be random function, an inline piece of JavaScript code, a scriptable sampler, such as JSR223 Sampler, or... There are many options really, depending on concrete needs of that generated template ID. Again, a more specific question would help to narrow down your choices.
Classic "correlation" example.
Look for that generated ID in the previous responses (you can do it with the View Results Tree listener)
Once you detect it you need to extract it and convert into a JMeter Variable with a PostProcessor (the most commonly used is Regular Expression Extractor, however depending on the nature of your request you may consider to use others
Once you get the ID extracted and stored in the variable - substitute hard-coded value obtained via recording with the JMeter Variable
Repeat steps 1-3 for any other dynamic parameters or values. Or, consider a faster way of creating a JMeter test via alternative recording solution which performs the above steps automatically so you won't have to worry about detecting and handling dynamic elements. See How to Cut Your JMeter Scripting Time by 80% article for details.
You need to check response of the previous request. Normally ID will be created and can be found in the response of previous request and you can use that ID for next request.
You need to first find in which response the ID is being generated and the format of the ID. You can use firebug to see the response in HTML format and find where the id is.
Once you have the format of the id, create regular expression around it. Test it using regex tester that comes with JMeter. Or you can use rubular.com to check the correctness of your regex.
Once you have correct regex, use regular expression postprocessor on the request which returns the id and then use that variable in actual request that uses unique id.

Runtime Test Data for Testscript in TestComplete

I started using Test Complete to automate Desktop application.
The issue is scripts holds the value which i entered while recording and the value is hard-coded.
i want the pass the value during run time. how can i achieve it?
This depends on how you want to do this. If you want to put it to your test as a parameter from another test or using a project's test item, you can define a keyword test parameter (see Keyword Test Parameters).
If you want to make a human user specify a value on runtime (although this is not very "automated"), you can create a user form that will request this value (see User Forms - Overview).
And if you want to pass a parameter to your test using command line, you can use script to read parameters from the TestComplete command-line, assign a project variable with this value and then use this variable instead of a hard coded value. See ParamStr Method, ParamCount Method and Project And Project Suite Variables.
And if you want to feed your test with some data from an external source, you can do this using the data-driven testing feature of TestComplete. See Data-Driven Testing.

CakePHP and reusable approach

I would develop my CakePHP application in the most reusable way. I'd like to treat it as webservices, so I don't want to strictly bind controller with view. My idea is: controller just returns json info, the view calls the controller and get the json and make html output.
How can I realize that? Could be a good approch, developing pages rather than views, and inside that pages call the webservices previously developed.
You can even forget about creating view files, using $this->set('_serialize', array('people')); in your PeopleController::show()
Well Cake is kinda' works like this "out of the box". You can use Router::parseExtensions(); to define what type of data you would like to serve. For example in app/Config/routes.php:
Router::parseExtensions('xml','json');
This will make it possible to detect what kind of request is incoming. For example if someone requests:
www.example.com/people/list.json or www.example.com/people/list.xml, in your PeopleController's list() method you'd be able to detect what kind of resource is being requested - json or xml, or of course any other
extension you define. This is what the RequestHandlerComponent is used for. You can check if it is xml for example:
if($this->RequestHandler->isXml()) {
//Some code
}
The different extensions are only different representation of the data, so it shouldn't matter what exactly you're serving. From v2.1 Cake will automatically switch the view class when it sees a JSON or XML request, which takes us to the new JSON and XML views.
All you will have to do is provide the views in the appropriate places.
In View/People (as for this example) you would have:
..View/People/
list.ctp
xml/
list.ctp - XML view
json/
list.ctp - JSON view

Resources