How to parameterize a link object/element in QTP? - automated-tests

Please give me a hint how to parameterize a link element in QTP...As we can parameterize 'WebEdit' element/object ,can we parameterize 'Link' element/object and how can we?

By parameterizing, do you mean Parameterizing the properties of the Link element to identify it using Descriptive Programming? Or is it something else?? Please elaborate!!
You can build a function like the one below for each object type that you want to use.
public Function CreateLinkDescription(LinkInnerTextValue, LinkHrefValue)
Set objLink = Description.Create()
objLink("innertext").Value = LinkInnerTextValue
objLink("href").Value = LinkHrefValue
'Add any other properties that you want to specify in the same fashion as above
Set CreateLinkDescription = objLink
End Function

Related

Computed Property that uses itself to compute its value?

I want to have a computed property that tracks that historical max of another property. Both these attributes are a member of an ndb class.
My naive approach was the following:
number = ndb.IntegerProperty(default=0)
highest_ever_number = ndb.ComputedProperty(lambda self: self.highest_ever_number if self.highest_ever_number >= self.number else self.number)
The intent was to set the highest_ever_number to a new number if number ever surpassed highest_ever_number.
This doesn't work because highest_ever_number is initially unset. I cannot set it to a default value using "default=0". Is there a workaround to this?
Thanks
I don't think you can use such conditions inside a Computed Property. This whole functionality can be done within a function, so it doesn't need to be a ComputedProperty. A better alternative to this problem could be to create a class method and call it whenever necessary.
Instead of using a computed property, you should use a normal IntegerProperty but use a _pre_put hook (https://cloud.google.com/appengine/docs/standard/python/ndb/modelclass#hooks) to verify/update highest_ever_number.
I can't test it right now, but this might do the trick:
number = ndb.IntegerProperty(default=0)
highest_ever_number = ndb.ComputedProperty(lambda self: self.highest_ever_number if
self.highest_ever_number and self.highest_ever_number >= self.number else self.number)

How to create associations

Say I have a GRPC order that looks like this when generated:
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "something.Order" do
optional :uuid, :string, 1
repeated :shipments, :message, 2, "something.Shipment"
...
end
end
So an Order has many shipments. When I create the order to send back as a response in the service... how do I create the many shipments?
Can I just do:
order = Order.find(request.id)
Something::Order.new(uuid: order.id, shipments: [order.shipments)
Or does it needs to be:
order = Order.find(request.id)
Something::Order.new(uuid: order.id, shipments: [order.shipments.attributes)
I get the latter from these docs
I'm not sure but it looks like the google-protobuf package is used here?
(https://github.com/google/protobuf).
If that's the case, I don't think the ruby-protobuf docs are relevant here.
For using Google::Protobuf here, it looks like you should be able to add an array of Shipment objects to the 'shipments' field of an 'Order' instance.

calling list item where var = value

is there a way of calling a specific list of lists without having to check (or loop) them all?
it is easier to understand with an example....
lets say
callList(5).key = "1234"
callList(5).callOpened = "11/26/13"
now i want to do something like
textbox_callOpened.text = callList(where key = "1234").callOpened
i also need to know what index that was at for there are many more items that i need to output too.
You can use LINQ. Add Imports System.Linq at top of the file and use First method with lambda expression as a predicate to get what you need:
' that gives you item matching your predicate '
Dim item = callList.First(Function(x) x.Key = "1234")
' you can use it to set the property '
textbox_callOpened.text = item.callOpened
pseudo code, didn't test but should work
dim something = callList.firstordefault(function(d) d.key = "1234")
if something is not nothing then
textbox_callOpened.text = something.callOpened
else
'cant find an element with key 1234
end if

How to exclude unnecessary buttons in ALV toolbar?

So, inside the TOOLBAR event of the CL_GUI_ALV_GRID the parameter E_OBJECT has the table MT_TOOLBAR that I can access to change all the buttons manually.
Is there a better way to include/exclude standard buttons in the toolbar than simply creating them like custom-buttons in the toolbar event?
Similar to REUSE_ALV_GRID_DISPLAY in class CL_GUI_ALV_GRID there is also a way.
Define a table of type UI_FUNCTIONS and a work area of type UI_FUNC :
data: lt_exclude type ui_functions,
ls_exclude type ui_func.
Append the attributes of the functions you want to hide to the table:
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
append ls_exclude to lt_exclude.
The attributes of the standard functions all begin with the prefix MC_FC_, in addition, there is the prefix MC_MB_ for an entire menu in the toolbar.
Pass the table using method set_table_for_first_display with parameter it_toolbar_excluding
If you use REUSE_ALV_GRID_DISPLAY in your code, this might be helpful for you:
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = 'ZPROGRAM'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_fieldcat = it_fieldcat
tables
t_outtab = gt_itab.
Your SET_PF_STATUS should be like this in order to eliminate some of the buttons you want. In this example I'm eliminating the "SORT_UP" button.
form set_pf_status using rt_extab type slis_t_extab.
data: lv_flag VALUE 'X'.
if lv_flag is not INITIAL.
append '&OUP' to rt_extab.
endif.
set pf-status 'STANDARD' excluding rt_extab.
endform. "set_pf_status
Hope it was helpful.
Talha
class lcl_event_alv definition .
public section .
methods handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive sender.
class lcl_event_alv implementation .
method handle_toolbar.
delete e_object->mt_toolbar where function = '&LOCAL&INSERT_ROW' or function = '&LOCAL&DELETE_ROW'
or function = '&LOCAL&APPEND' or function = '&LOCAL&COPY'
or function = '&LOCAL&PASTE' or function = '&LOCAL&CUT'
or function = '&LOCAL&COPY_ROW' or function = '&LOCAL&CUT'.
endmethod.
data : go_event type ref to lcl_event_alv.
create object go_event .
set handler go_event->handle_toolbar for go_grid1.
call method go_grid1->set_table_for_first_display
exporting
is_layout = gd_layout
is_variant = value disvariant( report = sy-repid handle = 'GO_GRID1' )
i_save = 'A'
changing
it_fieldcatalog = gt_fcat1
it_outtab = gt_items1.

How do I create variable paths using e4X?

I need to know how I can parse a variable path in Flex 3 & e4X. For example, I have two XML strings where the name of one element is the only difference.
<NameOfRoot>
<NameOfChild1>
<data>1</data>
</NameOfChild1>
</NameOfRoot>
<NameOfRoot>
<NameOfChild2>
<data>2</data>
</NameOfChild2>
</NameOfRoot>
Currently I am accessing variables like this:
var data1:String = NameOfRoot.*::NameOfChild1.*::data;
var data2:String = NameOfRoot.*::NameOfChild2.*::data;
I would rather make this task more abstract so that if "NameOfChild3" is introduced I do not need to update the code. For example:
var data:String = NameOfRoot.*::{variable}.*::data;
Does anyone have insights into how this can be done?
Use the child property (LiveDocs example here):
var tagName:String = "NameOfChild1";
var data:String = NameOfRoot.child(tagName).data;
That's with no namespacing--not sure whether it's necessary in your case, but I assume you'd add some *::'s?
this also works:
var data:String = NameOfRoot..data;
but if you have more than 1 data node you'll have to sort some stuff out.
It looks like the ".*." operation will work. I wonder if this is the easiest way to handle this problem.
var data:String = NameOfRoot.*.*::data;

Resources