Record without adding to repository? - vbscript

Imagine creating a new QTP project. You hit record to get your first bit of code in place. By default, you'll get something like:
Browser("MyApp").Page("MyPage").WebEdit("MyLogin").Set "Bob"
And you'll get the Browser, Page, and WebEdit objects automatically added to the repository. What I would like to be able to do, as one of those QTP bods that prefers descriptive programming, is hit record, and get something like:
Browser("name:=MyApp").Page("name:=MyPage").WebEdit("name:=MyLogin").Set "Bob"
And have no objects added to the repository. Is there a setting / option to do this somewhere?
(Obviously there are arguments for not wanting to do this, which I acknowledge and appreciate - but for those of us that prefer DP, this could help expedite test creation).

From what i understood is that you want to hit 'Record' button and you will get the script in descriptive type rather than the usual. But that is not possible.
For descriptive programming, you have to explicitly write the code by identifying the properties of each object for that (you can use Tools > Object Spy).
For above example:
Go to Object Spy > Select "the pointing hand symbol button" and click on the WebEdit for which you want to set the text "Bob"
Now, from Object Hierarchy select each object Top to Bottom and write properties of those object in the script. Like 1st Browser, then Page, then WebEdit. Try adding as more properties as you can.
You just can not get descriptive script by hitting Record button.

Related

InstallShield: Get the organization name during installation

I'm creating an installation with instalshield.
In the "Installation Interview", (which is part of the "Project Assistant") I set the option "to prompt users to enter their Company Name".
My question is: how can I interact with the value they entered? I mean how can I get it? I need to take this value and insert it to my app config file , during the installation process.
In a more general way, I would love to know how can I add text fields of my own and interact with the values the customers insert?
Thank you,
Noam
Look at the installation Wizard Noam. Anywhere you see an edit control, you will notice that it has a property associated with it. The property is a 'variable' that will have a value assigned to it. You can use the property to populate a registry, an XML file, etc.
I would look through the help documentation for InstallShield relating to Properties.
http://helpnet.flexerasoftware.com/isxhelp19/helplibrary/IHelpISXPropertiesUse.htm
The link above goes over the difference between Public and Private properties and how you can use them.
Ok, so I sort of solved it, I didn't use any built in dialog boxes, but simply created my own public property and dialog, then added an event to dialog and finally read the property value with powershell script, in more details (for future noobies) :
Create new property in Property Manager (under "Behavior and Logic"), give it a name and default value.
Create new dialog (under "User Interface").
At the behavior section of your dialog go to "Next" control (for example).
Add event (by pressing the tiny green plus sign at the line of the "Events")
Choose "SetProperty"
At the SetProperty line you can specify a condition, for example ApplicationUsers = "AllUsers"
At the "Property" field enter the property name (from first instruction)
At the "Value" field enter the value you wish for.
For getting the property value from powershell, create powershell script with the following: $value = Get-Property -Name PROPERTY_NAME
That's it.
This is not exactly what I asked for in the question but I believe this answer is more general and so also contains the answer to my original question.

How to replace a Control Array with individual Controls?

A previous programmer has created a form with a control array, containing the following controls:-
Command1(0)
Command1(1)
Command1(2)
and I am attempting to replace them with
cmdMeaningfulName
cmdOtherMeaningfulName
cmdThirdMeaningfulName
So far I have managed to rename the controls. This leaves me, however, with a set of controls:-
cmdMeaningfulName(0)
cmdOtherMeaningfulName(1)
cmdThirdMeaningfulName(2)
I can fiddle with the Index properties to get:-
cmdMeaningfulName(0)
cmdOtherMeaningfulName(0)
cmdThirdMeaningfulName(0)
but this still leaves a control array, resulting in methods like
cmdMeaningfulName(Index As Integer)
being generated (or required). Later - these methods don't actually compile, being reported as
Member already exists in a object module from which this object module derives.
when it clearly doesn't.
How does one remove the index entirely? I have tried editing the .frm by hand and no trace of any index can be found there.
On the form, select the control, then go to the properties window (F4). You can then select the index property and clear it. The control is then no longer an element of an array. This also means that any event handlers (_click, etc) are no longer hooked up, so you'll need to copy/re-implement those.

Is is possible to use variable in dialog prompt in LUIS?

In LUIS if you require some parameters for an action, and add a prompt question, if the parameter is missing, it will send the prompt as a dialog option in the answer.
In my case I have 2 required parameters, and if the 2nd one is missing (the quantity) I'd like the prompt asking for clarification to use the value of the other parameter's value.
For example:
query: I would like to buy tickets to toronto.
dialog prompt should
be: How many tickets to toronto?
I tried setting the prompt to something like "how many tickets to {location}" but obviously this doesn't work.
I haven't found any information on this so I think it's just not possible but I'd like confirmation.
I don't think this is possible out of the box. However, I believe it could be done if you start overriding things here and there.
The main problem is that the LuisActionDialog (the dialog that prompts for parameters) is not receiving the original LuisResult model (which makes sense since it's not serializable).
So, I think that to start looking into this, you will have to:
Override the MessageReceived method from the LuisDialog class, in order to create a new dialog that handles the parameters. Please note that overriding the MakeLuisActionDialog method won't be enough, per what I explained before about not receiving the original LuisResult.
Create a new dialog similar to the LuisActionDialog, that will do what the current dialog does but also performs the prompts manipulation that you are looking to have.

Buildup and reference of objects in HP UFT

I'm wondering how I can access properties/methods via console/watch.
I have the following code:
Dim page
page = Browser("Welcome: Mercury Tours").Page
Now I want to obtain the title of this Page. Since I inspected the Page object with Object Spy and I saw it has a title property.
When I enter page.title in my watch however, it tells me that page does not contain the property.
1. What is the correct syntax?
2. Why is this not working? I presume that the watch is checking for VBScript object properties instead of TestObject properties?
(I have a programming background and I find it very confusing that I have VBObjects and TestObjects simply walking through the same file. It kind of feels like a black box :/)
Ok, well, your syntax is incorrect...
It appears that you're trying to put something into a variable called "page", but I'm not sure if I can figure out your intention.
If you are trying to put the page object into the var "page", you would need to use a set statement (to indicate to vbscript that it's going to hold an object, not just a single piece of data)...
Regardless of that, your syntax for specifying the Page is wrong.
In your example, you're specifying a browser test object called "Welcome: Mercury Tours" from the repository... but then you put .Page - and that's where your syntax error is.
It helps to understand the difference between Test Objects and Realtime Objects - because you need to specify a page Test Object. You can do that by specifying a page object from the Object Repository, or you can do it descriptively.
Test Objects are descriptions of real objects that QTP tries to find. If it successfully finds a real object that matches the description, then the Test Object kind of (virtually) "attaches to" the real object... then, you can use the test object to query the real attributes of the real object that it attached to.
Sincel you're clearly doing the tutorial, your object repository probably has a Page test object in the heiarchy under the browser object... (and if you had let Intellisense help, it would show you a list of pages to choose from while you type...). If so, you would specify the page object like this:
Browser("Welcome: Mercury Tours").Page("PageObjectNameHere")
If you would prefer to use descriptive programming, you could instead type something like:
Browser("Welcome: Mercury Tours").Page("Title:=Welcome: Mercury Tours")
Changing your syntax to either of those constructs would let you proceed with the next part of solving your question - how to get some data from the page...
So, once you have address the page test object correctly, then you can specify a method to get information from it... such as .GetROProperty()
You can choose from many properties for a page... If you examine a page using GUISPY, it pretty much gives you a list of the properties available to query... For example, if you want to check the URL of the page that's displayed, you could specify
Browser("Welcome: Mercury Tours").Page("Title:=Welcome: Mercury Tours").GetROProperty("url")
This, of course returns a value, so you want to do something with it... like assign it to a variable
result = Browser("Welcome: Mercury Tours").Page("Title:=Welcome: Mercury Tours").GetROProperty("url")
(If you do this, you can then add the variable "result" to the watch list... which answers your question.)
or examine it directly in your code
if Browser("Welcome: Mercury Tours").Page("Title:=Welcome: Mercury Tours").GetROProperty("url") = url_to_compare then DoSomething()
I hope this helps to clear up your understanding :)

QTP Visibility Issue with a strange solution

I'm testing a Java web application on QTP. In one screen, not all fields are visible initially (ie: they're 'below the fold'), so this:
Browser("x").Page("y").JavaApplet("z").JavaInternalFrame("a").JavaEdit("txtName").Set "bob"
Causes an unspecified error to occur.
But if I change it slightly, to:
Browser("x").Page("y").JavaApplet("z").JavaInternalFrame("a").JavaEdit("txtName").Object.SetText "bob"
It works fine. Why?
If the object Properties for the JavaEdit Box which is set by the Developers is different from other similar objects. hence it has to be done in that way.
There are many instance like where one cell of the Java Table is set by the value using SetCellData for the Edit operation and for a same kind operation usually we use Type / SendKey methods.

Resources