Cannot set property with previously defined property in botbnt framework composer - botframework

I am working on a bot build with Microsoft bot framework composer
I have an HTTP request that works and returns an array of programs
Currently, I have a "0" hard set and that works
${dialog.programlistlite.api_response.content.programs[0].name}
what i am trying to do is take property called dialog.resultnumber which is set to 0 and replace static "0" above with property called dialog.resultsnumber
I tried:
${dialog.programlistlite.api_response.content.programs[${dialog.resultsnumber}].name}
${dialog.programlistlite.api_response.content.programs[(dialog.resultsnumber)].name}
${dialog.programlistlite.api_response.content.programs[dialog.resultsnumber].name}
${dialog.programlistlite.api_response.content.programs[getproperty(dialog.resultsnumber)].name}
${dialog.programlistlite.api_response.content.programs[dialog.resultsnumber()].name}
${dialog.programlistlite.api_response.content.programs[${dialog.resultsnumber()}].name}
I cannot find the syntax to use an already defined property to build a new property

what i am trying to do is take property called dialog.resultnumber which is set to 0 and replace static "0" above with property called dialog.resultsnumber I tried:
Are you sure that dialog.resultsnumber is an int?
If you set it in a single set property action, make sure you set it as an int, the default is a string.
This below should be the one. It worked for me (with the above caveat):
${dialog.programlistlite.api_response.content.programs[dialog.resultsnumber].name}
You can also use the isInteger() type checking function to confirm if something is an int, or try and force/convert/coerce using int() if needed as well.

Related

Gradle - Get the default value (convention) of a Property

I want to achieve a very basic thing (in any normal language): I would like to get the default value (convention) of a Property. Gradle docs in chapter Lazy configuration, describes how to apply the convention to a Property:
def property = objects.property(String)
// Set a convention
property.convention("convention 1")
println("value = " + property.get())
// Can replace the convention
property.convention("convention 2")
println("value = " + property.get())
property.set("value")
// Once a value is set, the convention is ignored
property.convention("ignored convention")
println("value = " + property.get())
The problem is, that you cannot query the property to get information what is the convention (the default value) when you set a value. It seems that the only way it's to clear (nullify) the value:
property.value(null).get()
But this is just stupid because you are doing unnecessary actions, while the convention is somewhere there?
Does anyone know how to get it without clearing the value?
The answer (for 2022) is: No, you can't get the default value (convention) of a Property.
I'll try to answer why set overrides the convention once it's called. The convention is the default value, once the property has a value by calling set the convention is ignored because the property has a value. That makes sense because that's what a default value should mean. If I have a value use that otherwise use this default value. Convention and set seem to follow that pattern. I don't quite follow why this is surprising to how you want to use gradle, but just as an outside observer I think gradle is doing what is expected.
You can test if a property exists using
if( property.isPresent() ) {
// do whatever
}
I bet that isPresent() is going to say false when the convention would be returned by get(), but if you call set then isPresent() is going to return true.
Then there are other methods to help like:
def val = property.getOrElse( "SomeDefault" )
def maybe = property.getOrNull()
I do think Gradle doesn't always do a good job of making the API very accessible from their home page and docs (ie groovydoc) for answering more complex questions:
https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html
These methods are the super interface Provider and hence why it may not be obvious they are available if you don't look up the chain:
https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Provider.html

Golang Google Admin SDK API Client not setting boolean properties correctly

I am using golang package google.golang.org/api/admin/directory/v1 v0.28.0 to build an administrator CLI for Google G Suite.
The User type (and other types as well) has boolean properties with omitempty json tags. I can set these properties to a value of true, but when I try to set them to false, nothing happens. I believe that this is because the omitempty option means that the value false is ignored when passed.
After a bit of web research, it seems that the answer might be to use pointers and change the type of the boolean properties from bool to *bool. Then set the value by using a bool pointer like this:
user := new(*admin.User)
f := new(bool)
*f = false
user.Suspended = f
I'm not sure why this might work, but it was suggested and confirmed as working in respect of another API.
These API client libraries are auto-generated and I'm not sure how I can test my theory. If anyone has come across this issue in the past, is there a remedy or workaround for it? Could anyone suggest how I can generate my own version of the golang client?

HP-UFT object not found in object repository error

Getting the following error while executing script:
WebList object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.
Line (1221): "objParent.WebList(vstrObjectName).select vstrValue".
I understand, it shouldn't be as simple as the object isn't available in the repository but in in case- Try to use 'Locate in repository'
It looks like Line (1221) is trying to access a WebList object by name, but the name is stored in a variable; it is not a string literal in the code.
There might be 3 different things going on here.
1) if you were attempting to use Descriptive Programming, then it sounds like the contents of vstrObjectName didn't include the ":=" symbol that would make QTP believe the string is a description... So, QTP thinks the string stored in vstrObjectName must be the name of an object in the Object Repository.
I would like to guess that you were trying to use descriptive programming, since (based on the fact that the parent, and the parameter are also both contained in variables) it looks like you are avoiding using any string literals in that line.
2) If you were attempting to control an object with a name from the Object repository, then either the string contained in vstrObjectName didn't contain a valid object name (that belongs to objParent), or
3) the object refered to by objParent isn't the one you were expecting.
In any of these cases, if it were me, the first thing I would do is add a print statement before line 1221 as:
Print "vstrObjectName:'" & vstrObjectName & "'"
...and run it again. That should show the string that you were referencing. I would guess that the resulting output line is not what you expected.
Another thing to check is to make sure that the action or function that contains that line is executed from within an action that contains that named object in it's OR scope. (i.e. open the action and hit CTRL-R, it shows the combined OR that is visible to that action). If the line is in a function library, and it gets called from an action that doesn't have the object in it's local OR, or an attached shared OR, then you will get the same error. This kind of problem is very easy to cause if you use multiple actions, and the action containing the call to the function that contains your line (line 1221) doesn't actually have that object available to it due to it's OR scope.
To answer the question you asked - how to add object into the OR - you could use several methods - recording, guispy's add to OR button, manually add from the OR screen, etc... but in the end, you need that object in the OR to have a name that matches whatever is in vstrObjectName.
Some potential examples where an object can be selected:
Dynamically change the object based on the name of the object in the object repository:(must exist in the repository)
Dim objectname
objectname = "SAP Work Manager"
msgbox WpfWindow(objectname).Exist
Select an object that does not exist in the Object repository, by its properties:
WpfWindow("text:=SAPWorkManager").Exist
Example page of UFT tips

Grails define custom error message for command object

I am writing a Grails (2.3.3 currently) application and have created a validateable command object similar to the following:
#Validateable
class MyCustomCommand {
String name
static constraints = {
name blank: false
}
}
In my i18n/messages.properties file I defined the following properties to override the default error messages.
MyCustomCommand.name.blank=Name must be provided.
MyCustomCommand.name.null=Name must be provided.
Which per the Grails documentation should be of the format [Class Name].[Property Name].[Constraint Code] as I have done. When I run my application if I leave the value blank I still get the default message for a null property.
I also tried following the example of the default messages and defining them a follows, but still get the default message.
MyCustomCommand.name.blank.message=Name must be provided.
MyCustomCommand.name.null.message=Name must be provided.
I am assuming that I am missing something simple here, but have yet to stumble upon what. Any suggestions on what I am doing incorrectly?
It is simple indeed. Message should look like:
myCustomCommand.name.blank=Name must be provided.
myCustomCommand.name.nullable=Name must be provided.
//className.propertyName.blank (camelCase with first letter of class name lower)
So, as I anticipated it was something simple. I was using the defaults as an example which used null where as what I really needed was nullable. Which does make sense as that matches the constraint name.
Therefore the correct version is:
myCustomCommand.name.blank=Name must be provided.
myCustomCommand.name.nullable=Name must be provided.

using WebEdit .Type property cannot be used

I have a piece of code in using QTP for a webpage
Browser("Sarit_2").Page("Sarit").WebEdit("frm_vendor_address1").Set dtVAdd1
You will observe, I used a 'Set' property. In reality, I wanted to use a 'Type' property because soon I will write script to check field limit and .Set property throws an error when I try to set a value larger than the field length. But Type property(I used it in win32 app), it types as much as the field length but at least doesn't throw an error I can't handle.
QTP in WebEdit or this particular WebEdit does not allow me to choose .Type. How come it allowed me in the case of SWFfield?
Any suggestions?
"Type" is a method used for Windows application, Delphi, Java, swf etc... But it is not used for Web application.
For web application we have to use "Set" method. Therefore above piece of code accepts 'Set' method. This also tells why you can not use 'Type' method with web based object.
If you want to count the field limit, you can object spy on the webedit-> save its max length value to any variable-> at run time store max length of that web edit field to variable2 using 'Browser("...").Page("..."). .... .GetROProperty("max length"). Now compare the two variable with if statement.
The WebEdit test object is helpfully trying to prevent you from setting an invalid value into the edit field.
You obviously don't want this help the question I'm not clear on is what you're trying to accomplish. If you want to set the first part of the string up to maxlength you can do something like this:
Public Function SetLimit(ByRef test_object, ByRef Value)
max = test_object.GetROProperty("max length")
If Len(Value) > max Then
test_object.Set Left(Value, max)
Else
test_object.Set Value
End If
End Function
RegisterUserFunc "WebEdit", "Set", "SetLimit"
You could use the WScript shell object to send keystrokes to the WebEdit after focussing it (by clicking into it). Like shown in http://h30499.www3.hp.com/t5/Quality-Center-Support-and-News/QTP-cannot-input-value-to-Webedit-field/td-p/4206627#.UkRMyIbIYyg:
Set WshShell = CreateObject("WScript.Shell")
Browser("Sarit_2").Page("Sarit").WebEdit("frm_vendor_address1").Click
WshShell.SendKeys(dtVAdd1)
Set WshShell = Nothing
Note that dtVAdd1's value must then conform to the format SendKeys expects -- as documented in (for example) http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx.
Alternatively, you could use the undocumented Mercury.DeviceReplay interface to send the keystrokes. This is easily googleable.
As we know WebEdit does not supports Type method, we can use alternate approach like
1.SendKeys
Set objClick = CreateObject("WScript.Shell")
Browser("Sarit_2").Page("Sarit").WebEdit("frm_vendor_address1").Click
objClick.SendKeys "dtVAdd1"
Set objClick = Nothing
http://www.ufthelp.com/2013/02/sending-keyboard-strokes-in-uft-115.html
2.Using Native Object properties
Browser("Sarit_2").Page("Sarit").WebEdit("frm_vendor_address1").object.value ="dtVAdd1"
but this is almost similar to Set method
3.Using Advance Run settings in UFT
Tools->options->GUI Testing ->Web->Advance->Run Settings->Replay Type ->Mouse

Resources