I have created a webtest in visual studio to perform a test on a Rest API.I have some code that generates a random serial number that i need to pass into my QueryString parameter is there anyway to do this? I noticed that i can bind xml, csv and a database to it for Dynamic values. Would i have to change my code to wright to a xml file or is it possible to perform a direct call to the method inside the .cs file? C# Langauge.
I want to do something like in the below method but i want the sessionToken.sessionToken() to be the method that was called from the .cs file.
QueryString Parameters
generatedToken=sessionToken.sessionToken()
Write your code within the PreRequest method of a Web Test Request plugin, or call your method from the plugin. One of the last statements of the plugin should write the generated value to a context parameter, with code something like:
e.WebTest.Context["YourContextParameter"] = TheGeneratedValue.ToString();
The value of the query string parameter can then be in one of these styles
{{YourContextParameter}}
or
Some text{{YourContextParameter}}more text
With a little more effort you can pass the context parameter name as a parameter of the plugin.
It can be useful to add diagnostics from the plugin into the log; to showit has been called and to record its output. This can be done with a statement of the form:
e.WebTest.AddCommentToResult("Plugin result is " + TheGeneratedValue.ToString());
Another approach is to convert the entire webtest to a coded test, by using one of the command icons just above the webtest. That produces C# that you can edit as much as you want. However, that conversion is a one-way process. After doing it you cannot use the webtest editor to further change the test. Hence I recommend the plugin route.
Related
I am trying to work out how to pass a particular piece of data in a POST via a Visual Studio Web Test, without it being recognized and treated as a Context Parameter.
The POST contains a (string) body that is a json document. Part of the body includes something like the following:
"My Attribute":"Some test surrounding this {{SomeValue}} other stuff"
The issue is that the Web Test is trying to match {{SomeValue}} to a Context Parameter (which doesn't exist) and so this request fails.
The value is legitimate, and needs to be sent with the request as is.
I've done some Googling and can't find any documentation that talks about, for example, escaping this string so that the value will be passed correct, and won't be treated as a Context Parameter.
I guess I could write a Web Test plugin to intercept this particular request, and do some token replacement, but that feels like a sledgehammer approach.
Any other ideas?
You could create the context parameter SomeValue and set its value to {{SomeValue}}.
You could create the two context parameters OpenDoubleCurly and CloseDoubleCurly set to the values {{ and }} respectively. Then modify the POST text to be:
"My Attribute":"Some test surrounding this {{OpenDoubleCurly}}SomeValue{{CloseDoubleCurly}} other stuff"
Normally web tests only do one level of context parameter expansion. You need to use (or for this question avoid using) plugins that do multiple expansion passes.
How can I render the CodeEffects Rule Editor in a different language (Let's say Arabic).
I am using a custom class as the source object for the rule model and passing that in the viewbag to the view, there i am rendering the rule editor using that. I have not explictely called any source xml or help xml doc. the rule editor is picking the default english version.
#{
Html.CodeEffects().RuleEditor()
.Id("ruleEditor")
.SaveAction("SaveGroup", "Campaign")
.DeleteAction("DeleteGroup", "Campaign")
.LoadAction("LoadGroup", "Campaign")
.Mode(RuleType.Evaluation)
.ToolBarRules(ViewBag.ToolBarRules)
.Rule(ViewBag.Rule)
.Render();
}
So far on CodeEffects official documentation I have come accross this Help XML and Multilingual Support in Code Effects but I couldn't understand it properly
How can I load a custom help xml and source xml file from the cshtml page using razor syntax
Any help would be appreciated.
In general, you simply create your own version of the Help XML in your language and pass it to the editor on the server using the editor's HelpXmlFile property during the editor initialization.
You also need to have your own version of the Source XML with all display names translated in your language if you want your fields, in-rule methods and rule actions to be displayed in your language on the client. You can pass that source xml to the editor using the its SourceXmlFile property.
Call editor.GetHelpXml() method to get the default version of the Help XML to be translated; call editor.GetSourceXML() to get the Source XML of your source object to be translated (pass your source class to your editor first before calling that method, of course.)
EDIT:
As I said earlier, you need to use your own custom version of the Help XML which sets language-specific labels of all static UI elements such as buttons, Help String, etc. To do that, create a default instance of the RuleEditor class and call its GetHelpXml() method. That gives youa string of the default English xml document. Translate all its node values to your language, save it and pass that new xml to the editor using one of the overloads of its Help() extension method. Details can be found here.
I assume that you also need to have all properties, in-rule methods and rule actions displayed in your language. You have two options here:
If your project only uses one language, then simply use the FieldAttribute, MethodAttribute and/or ActionAttribute to set their DisplayName properties to values in your language. Details are here, here, and here.
If your project uses multiple languages then create an instance of the RuleEditor class, set its SourceType property to the type of your source class and call its GetSourceXml() method whoch returns a string of the XML doc that represents your source class. Create a copy of that doc for each of the language your project uses, translate all value of the "displayName" attributes in correspondent language, save those files and pass the desired one to the RuleModel.Create() method when you init the editor on the server. Details are here.
I've been trying to use the TSqlModel method DeleteObjects to programmatically remove certain users from a Database project. The problem is that when I call the method, the user remains in the model. I wonder if I am calling the method correctly. Here's something close to what I am doing:
modelFromDacpac.DeleteObjects(#"DOMAIN\user");
When I run the following code to see if it's really gone, the user is still there!
var tst_delete= modelFromDacpac.GetObjects(User.TypeClass, new ObjectIdentifier(#"DOMAIN\user"), DacQueryScopes.Default).FirstOrDefault();
tst_delete is non-null and has a name that matches "DOMAIN\user".
Any idea what I'm doing wrong?
Prior to the DeleteObject method call, I insert the following line - where the sqlobj object is a TSqlObject referring to the user I am trying to delete
//For some reason, the logins aren't scripted objects within the DACPAC, and so cannot be deleted using the DeleteObjects method - or maybe they simply cannot be found.
modelFromDacpac.ConvertToScriptedObject(sqlobj, "DOMAIN_user.sql");
Then I call the DeleteObject method as follows:
modelFromDacpac.DeleteObjects("DOMAIN_user.sql");
I'm not sure why this works, but it does. My guess is that the DeleteObject method is pretty picky about how and where it expects to find objects. Or, maybe some objects, like users, are stored in some non-standard fashion which prevents DeleteObjects from finding them. Whatever the reason, but explicitly converting the user to a scripted object with a given name, and passing that given name to the DeleteObjects method, it works.
I am a little concerned that I do not know why it works. The other concern is that it doesn't show up in the official documentation of the TSqlModel object:
https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dac.model.tsqlmodel_methods(v=sql.120).aspx
But it does work. At least, so far.
DeleteObject caught me out the same way :) - it only deletes scripts added using AddOrUpdate when you also pass in a script name and Delete uses the same script name.
What you need to do is create a new model and add in everything except the things you want to delete.
Why do you want to delete a login? If you don't want it to be deployed you can use a deployment contributor like my one here to exclude the login at deployment time:
https://the.agilesql.club/Blogs/Ed-Elliott/HOWTO-Filter-Dacpac-Deployments
Ed
I have a Ranorex project* with two params which I have defined in Global Parameters and bound to modules in the test case. When I look at Global Parameters for the project, it says they are [Unbound] in the Module Variable column:
but in the Data Binding for the test case it shows them bound:
I have tried passing the parameters when trying to run the exe from the command line, as well as when running in debug mode using values entered in the Start Options from the Debug pane of the project parameters.
In either case the parameters are simply not being found by the project while running.
i am calling it from the cmd line thus:
$ src/main/resources/downloadAndInstall.exe /pa:downloadUrl="http://www.aone05281242.com/index.jhtml?partner=^1242^yyyyyy^YYA&sandbox=false" /pa:hostEntriesText="127.0.0.1 localhost"
output includes this line:
[2015/05/28 14:00:54.223][Info ][Data]: Current variable values:
$hostEntriesText = ''
As you can see it doesn't even report the other variable that I'm passing.
I also tried it without the quotes around params but that didn't help. Also, my second parameter actually has multiple lines so I'm not sure how to ensure I pass it correctly. However, I tried it with a single line for that param to eliminate it as a source of the bug. No joy. I'm pretty frustrated. Please help...
* "Well there's your first problem, you're trying to use Ranorex"
I don't think this is a bug.
There are two different types of parameters
param|pa:<global parameter name>=<value>
Creates or overrides values for global parameters specified in the test suite.
testcaseparam|tcpa:<name or guid of test case>:<parameter name>=<value>
Creates or overrides values for testcase parameters specified in the test suite.
You are using the global parameters in your call, but the variables are bound to the test case parameters.
Try to use the test case parameters.
I have been working on this for days and I just don't get the concept of how Custom Actions work with Wix. Or at least I don't see how to do what I want.
I have several XML files that I want to read a value from and populate a property that gets displayed in a UI Dialog. Then when the install begins update that value in another XML file.
I need to be able to pass the filename including path of the local XML file and the node to search for and the key value pair to extract. I also need to pass what property needs to be updated.
I understand the CustomAction DLL concept. And that the session.CustomActionData["parametername"] syntax for passing in parameters. And the session["property"] = to set a property.
But I can't figure out the syntax of the wsx code to make it all happen. I read different examples doing it different ways?
I searched all the Google links out there an nothing seems to fit what I want to do?
You want this to be an immediate custom action not a deferred custom action so CustomActionData has no relevance to you.
What I would do is write a custom table like such:
Id [PK]
File (Formatted)
XPATH
Property
Here's an example:
mySearch
[SOMEPROPERTY]
/test[#'test'] (something like that, I hate xpath)
MYPROPERTY
You can use things like Property/FileSearch to have MSI's AppSearch resolve the location of a file and assign it to [SOMEPROPERTY]. Then you write a custom action scheduled after AppSearch to fetch this table's data, iterate it and fetch the attribute value (or element innertext) of each row and assign it to MYPROPERTY.
InstallShield gave this to me for free. I don't think WiX has a built in extension to do this. Maybe there is a community extension out there. It would probably take me an hour to write a prototype of this in C#/DTF.