Ant: scan file and write property - file

In a file called foo.fxml in ${basedir} there is a section that reads
<!-- ANT SEARCH HERE 5 -->
where 5 may be any integer.
How can I get an ant property to hold the value of that integer, in this case, 5?

There's two steps to this. First, you need to read the file, which you can do with LoadFile. Then you can use a regular expression to get the number in the comment. Ant-Contrib has PropertyRegex which is good for this.

Related

Watson, types of condidions

I have one example.
I create some intent inside Watson Conversation, and I want to knows how I can do some condition for it?
Example:
Watson: Hi, tell me your number
Me: 99999-9999 (and have some regex inside advanced conversation flows, i check wih context variables in the case is number and works fine)
The conversation will only continue if he enters the 9 numbers correctly.
I try it:
check image
Use a regular expression to parse the input and extract the number using syntax similar to
then have a dialog node condition based on the number extracted.

In XDocReport, how to handle null value?

Is there a way to handle null value for a field in XDocReport? or do I need to manipulate it on my own? example:
if (thisVar == null)
context.put("sampleText", "");
else
context.put("sampleText", thisVar);
or is there an option in docx quick parts?
I found this line in the error message of XDocReport. However I could not understand where to apply this, in the template or in the code.
Tip: If the failing expression is known to be legally refer to
something that's sometimes null or missing, either specify a default
value like myOptionalVar!myDefault, or use [#if
myOptionalVar??]when-present[#else]when-missing[/#if]. (These only
cover the last step of the expression; to cover the whole expression,
use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
In docx, append ?if_exists to the field name
«${tx.amount?if_exists}»
you may also append !
«${tx.amount!}»
Please refer to this link for those who uses freemarker. How to check if a variable exists in a FreeMarker template?

FindResource() doesn't find my resource

I have some code template that i compiled, i would like to understand one part of the code that i am can't figure out what it does although i have spent a whole day tried to.
the code in question is as follows:
#define IDR_STUB 1
hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_STUB), "STUB");
I have another two files in the same directory as the main file, the first one is called `something.rc' and is content is:
#define IDR_STUB 1
IDR_STUB STUB DISCARDABLE "stub.exe"
The other file as you can guess is stub.exe.
My question is what is wrong with the FindResource call above that it can't find whatever is trying to find, I have hard time to understand how that function is suppose to work.
So if you can give me some help i would be glad :)
THX.
Had the same problem. I solved it by using string resource id as described in MSDN:
If the first character of the string is a pound sign (#), the remaining characters represent a decimal number that specifies the integer identifier of the resource's name or type. For example, the string "#258" represents the integer identifier 258.
So try the following code:
hRsrc = FindResource(NULL, "#1", "STUB");
I've stuck in the same issue, when tried to use predefined resource type RC_DATA.
FindResource(hInst, MAKEINTRESOURCE(name), RT_RCDATA);
This code was returning NULL whatever I did.
So when you edit your .rc file you should use constant RCDATA, but when you call FindResource() you should use constant RT_RCDATA. Be careful. Hope I've helped someone.

Ant script : Replace only the value of the key in a java property file

I'm using this script to replace a value in a property file located into a jar file.
<replace file="/cygdrive/d/ant/test/target/com/test/resources.properties" token="MyKey" value="MyNewValue">
the property file is :
MyKey=My Old Value
This script will replace MyKey by MyNewValue
Or what I need is to replace the My Old Value by the MyNewValue?
You might use the Ant propertyfile task, something like:
<propertyfile file="/cygdrive/d/ant/test/target/com/test/resources.properties">
<entry key="MyKey" value="MyNewValue"/>
</propertyfile>
The replace task is simple string replacement, and it did exactly what you asked it to do -- replaced the occurrence of the string "MyKey" with the string "MyNewValue" in the properties file (it doesn't know it's a property file, just treats it as text.) If you want it to replace "My Old Value" then that's what you'd specify in the token parameter.
If you're just looking to have placeholder values in a properties file that you set at build/deploy time, then you might want to look at the filter task if you have lots of properties to deal with.

Selenium IDE - Typing values stored in an array into a textbox?

There's a webpage I'm trying to test that has multiple textboxes. I've gotten to the point where I can retrieve all the values in every textbox and store them into an array, but I'm stuck on how to type those same values into the textboxes again.
Here's what I have so far in Selenium:
Larger view: http://i.stack.imgur.com/rb93k.png
The stored variable 'count' is simply the number of rows in the table, and isn't causing a problem. The part I've circled in red is where the problem comes in.
When I run this test, instead of typing the value stored in the array at that index, it simply types:
This continues all the way until the end.
The variable 'i' is properly inserted, but for some reason instead of grabbing that value, it simply types it into the textbox.
Does anyone know how I can get the correct value in the array?
Below is the problematic line:
type | javascript{this.browserbot.getUserWindow().getTestingHooks('TextBoxValue_' + storedVars['i'])} | ${textBoxArray[${i}]} |
i'm using Selenium library through Robot Tests Framework. I'm not using any IDE, just using HTML to make test cases and defining new keywords.
When ever i want to access a list variable item, i just use the following sintaxe
#{list_variable_name}[0]
note that ${variable_name} is to access a single value variable or the reference to the list variable. If we want to access a list item we need to use # instead of $.
If i understand your situation right,
#{textBoxArray}[${i}] should work for you.
Try also
${textBoxArray}[${i}] because it seems that your are simply misplaycing the last }.
More details at
http://robotframework.googlecode.com/svn/tags/robotframework-2.5.4/doc/userguide/RobotFrameworkUserGuide.html#list-variables
I think you need to replace your circled reference to ${textBoxArray[${i}] with
javascript{storedVars['textBoxArray['+storedVars['j']+']']}
Read this blog post for more information, especially the section about 'Setting and getting variables'.
Quoting from the article, consider
store | 10 | x
This obviously sets x=10. There are a couple of ways to reference it:
${x} or storedVars['x']. They're not the same.
In particular
You can't assign anything to ${x}.
You can insert one more command before your problematic line:
getEval | storedVars['text'] = storedVars['textBoxArray'][storedVars['i']];
And change problematic line to:
type | javascript{this.browserbot.getUserWindow().getTestingHooks('TextBoxValue_' + storedVars['i'])} | ${text}
Also it will be probably helpful to declare your array in the beginning of the test:
storeEval | new Array() | textBoxArray

Resources