UFT: Problem in extracting data from excel file and input in the application dynamically - hp-uft

I am facing issues in performing certain actions based on the value in the excel file cell data.
Actions like if value is "NORMAL" then click Container type = Normal (radio button)
Similarly the Unit Container Value
Following is my code:
I am getting this error while performing action .WebElement("Container_Type_Normal").Click

Your error is because you can't start a line with . unless your within a with - and i can't see a with in your function. (i also don't recommend using a with as the can cause needless confusion)
The .webelement object is a catch-all type of object that is the child of other web objects or .page. You need this to be a full and valid path to the object, by this i mean start with browser().page().
You have a couple of options:
You can either make this a full path to your object based on the object repository:
Browser("<<OR Browser name>>").Page("<<OR Page name>>").WebElement("<<Your webelement name>>".click
For this, look at your OR and insert your names.
Or, option 2, you can use descriptive programming:
Browser("CreationTime:=0").Page("index:=0").WebElement("text:=" & fieldValue,"index:=0").click
That will take the browser that was created first (Creation time 0), the only page it has and the first (index 0) web element that contains your text (text is field value).
I'm assuming that you only have one browser, and that the first element that contains the text you want is what you want to click. You may need to add more layers too this or
A good approach is to mirror what is OR or use the object spy to ensure these properties are correct.

Related

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.

Record without adding to repository?

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.

Peoplesoft Peoplecode events

i am new to Peoplesoft software and the PeopleCode programming. I have been doing alot of exercises with PeopleCode. I have a question whereby the record fields events such as FieldDefault and etc etc....
I have made an application whereby user can search and add new value. So in a case where I have Peoplecode in one of the event for example SaveEdit, when I click the save button in both cases of search data or adding new value tab, it points to the same PeopleCode.
Is there any method whereby the code will know when user are searching existing data or adding value or rows in PeopleSoft?
Wont it be conflicting for both cases to point to the same PeopleCode?
Another question:
Hi i have a question regarding the passing of variables between the FieldFormula event and SavePostChange.
I have some values being calculated in the FieldFormula and I want to access it in SavePostChange event as I want to prompt messagebox based on the value being calculated.
I have been using the Global variables to access the variables.
Is there any good way to pass the variables or access to the variables values?
In the case of search records, there are a couple of Search-specific events, SearchInit and SearchSave. SaveEdit is when the record is saving so it shouldn't have a conflict with Searchevents.
Additionally you can place code either in the Record PeopleCode (fires every time someone uses that Record in a Component) or in Component Record PeopleCode (just that component). Record PeopleCode fires first then Component Record PeopleCode. The Component PeopleCode also has additional events that the record level ones don't, like SavePreChange and SavePostChange. So once you get the hang who fires when you can get pretty granular control of the various events.
There is actually a pretty good summary in the PeopleBooks here.
Regarding your question of how to differentiate between adding a new value and working on existing one, I would suggest you to use %Mode variable in peoplecode.
When working on existing value %Mode takes the value as "U" ie Update Mode
If %Mode="U" then
/**YOUR CODE**/
End-if;
When working on New value %Mode takes the value as "A" ie Add Mode
If %Mode="A" then
/**YOUR CODE**/
End-if;

Oracle Forms Builder - change to window in another form

We have two forms so far, and need to switch from window1 in from1 (which is login screen) to windowX in formX using button (trigger code below):
begin
show_window('windowX');
go_block('some_block_in_formX');
end;
This gives error FRM-41052: Cannot find Window: invalid ID
So question is, should I add formX into show_window parameter in certain way or is there another approach? Thank you.
Please note, that forms are in different files.
that forms are in different files.
If the forms are different files, you need to call the other form using open form/call form/newform - whatever suits your needs.
show_window/go_block sequence can be used only when you're moving to different windows/blocks of the same form - and the error message
error FRM-41052: Cannot find Window: invalid ID
is complaining that it can't go to that Window because it's in a different form.
Each form effectively has a private namespace for all its windows, blocks, items, etc - and your code always runs within the context of a single form.
To solve this, you'll need a form parameter, plus some code in the other form, e.g.:
in formX, add a parameter ACTION
in form1, pass the value 'XYZ' to ACTION
in formX, in the WHEN-NEW-FORM-INSTANCE trigger, check if :PARAMETER.ACTION = 'XYZ', and if so, do your show_window and go_block. Copy the same code to your WHEN-WINDOW-ACTIVATED trigger.
Of course, you'll need to think about the name of the parameter (e.g. ACTION) and value ('XYZ') that will make sense to people maintaining your forms in the future.

How to add components in to an existing GUI created by guide?

I just created a GUI using guide in MATLAB for a small project I'm working on. I have amongst other things two text fields for from and to dates. Now I'd like to get rid of them and use a Java date select tool. Of course this is not possible using guide so I need to add them manually.
I've managed to get them to show up by putting this code into my Opening_Fcn,
uicomponent(handles, 'style','com.jidesoft.combobox.DateChooserPanel','tag','til2');
using UICOMPONENT.
But even though it shows up I can't access the date select's attributes, for example
get(handles.til2)
returns
??? Reference to non-existent field 'til2'.
How can I fix this?
Unless you edit the saved GUI figure, the basic handles structure will not include your new component by default.
One way to access you component is to store the handle via guidata, by adding the following to your opening function:
handles.til2 = uicomponent(handles, 'style','com.jidesoft.combobox.DateChooserPanel','tag','til2');
guidata(hObject,handles)
Functions that need to access the handle need the line
handles = guidata(hObject)
to return the full handles structure that includes the filed til2

Resources