Count attributes with certain value xPath - xpath

Currently i'm trying to count the total of items that are selected with xpath.
to count all items i can do:
count(/process_data/formData/xdp/datasets/data/Data//#selected)
but how can i count all items where the value of selected is true. (not knowing the previous node). If i knew the previous node i could do:
count(/process_data/formData/xdp/datasets/data/Data//node[#selected=true]/#selected)
but since i don't know this data, i can't use this. any ideas?

If you mean by not knowing the previous node that you want to check all nodes that may have a selected attribute I think you just have to change your XPath expression to:
count(/process_data/formData/xdp/datasets/data/Data//*[#selected='true'])
This assumes that selected is actually a string attribute.

Related

Table Extraction in UIPath if table has images

I am trying to extract the Table which has the following format
When I want to extract i should have either put some character on place up icon or i dont want that either the case is fine..
But UIPath brings this way.. 78,59,237806 all as one text which is misleading.. How to resolve this issue..
Thanks
Take a look at the Find Children activity. You can specify an item via selector (the table) and use Find Children to return a collection of type UiElement.
So set the filter to extract the "<webctrl tag='tr' />" which will effectively give you a collection of the rows.
Use a For Each to iterate through each UiElement you got from the first Find Children activity, and use that element to run another Find Children. In this case, set the filter to extract the elements with a class of "mid-wrap". This gives you a collection of the elements in the row which match that requirement, and this will exclude the data-up value, since that's a different class.
You can then loop over this collection to get the innertext attribute, which will give you the actual values you're looking for each cell in the row. Use something like Add Data Row to add the values to a datatable, and let the For Each run over the next row in the collection.

Qlikview - show first and last selected value in list

I need to display first and last selected value in list. I have listbox and when I pick date I got this result in list
I want to get in one box min value selected but when I use minString(Data) I got 22/2022 instead 303/202. And for max I need to get 306/2022.
Can anyone help please?
To get the Qlik engine to ignore the selected values you need to set analysis.
Firstly, you should be using a max() not a maxstring(). Max() will evaluate the maximum numerical value. Maxstring() will evaluate the maximum ascii values of the string (I think, anyone can correct me).
Secondly, the value 306/2022 in that list is grey which means it is no longer included in the dataset used for the visualisations being displayed. The white values are the values that are included, this is why min(Date) is returing 22/2022. 22/2022 is the minimum available (white) value in that list. 303/2022 is the minimum value of the excluded values in grey.
If you want to be able to reference the values even when the selections have caused it to be excluded (turned them grey) you need to modify your max() to max({1}).
{1} means look at all the data not just the selected data.
max({1} Date)
will return 306/2022 no matter what the selections are.
If you want to return 303/2022. The minimum of the excluded values and have that change dynamically when making other selections let me know and I can show you but I will require you to explain why you would want to that before I try figure it out :)
You can try using the OnOpen document trigger.
enter image description here

How to map an element from the list to a single element in Tibco?

I obtain a list of elements from the JDBC. And then I have to map an element from the returned list to another single element of a different system. Could someone help, please ? I tried for-each, but couldn't handle it. Any hints would be helpful. Thanks.
Assuming the output of your JDBC query is something like this records.A and records is repeating.
You can use the following syntax records[1].A to map the first value of the list to a non repeating elements, or if you have another fields B returned by your query and want to select the data depending on B value you can do something like this : records[B=123].A, in that second example the first record found with B=123 will be mapped to your target element.

XPath only get nodes from table when another node exists

I have a specific problem concerning XPath.
Say I can get a column from the table using this query:
//div[#id="someid"]/table/tbody/tr/td[9]/text()
However, I want to only get this column when another specific node exists.
I tried using:
//div[#id="someid"]/table/tbody/tr/td[9 and boolean(//a/span[#title='specifictitle'])]
This however does not work as it returns all items in the table.
I have a few specific limitations:
- //div[#id="someid"]/table/tbody/tr is static and cannot be changed.
- The td contains no other info concerning what column it is in.
Thanks in advance!
2 approaches:
First - as a direct condition within square brackets:
//div[#id="someid"]/table/tbody/tr[//a/span[#title='specifictitle']]/td[9]/text()
this approach is simpler and the position does not matter
this is also the approach that fulfills the OPs requirement, that the query should start with //div[#id="someid"]/table/tbody/tr
* You can basically put the condition [//a/span[#title='specifictitle']] to whatever element in the query you want (could also be behind tbody or table etc.)
Second - using axes (for example ancestor)
2 cases regarding the position of your element within HTML code:
1) anchor-element "before" your div with "someid":
//a/span[#title='specifictitle']//div[#id="someid"]/table/tbody/tr/td[9]/text()
2) anchor-element "after" your div with "someid":
//a/span[#title='specifictitle']/ancestor::div[#id="someid"]/table/tbody/tr/td[9]/text()
In both cases the xpath-query will not return a result if the //a/span[#title='specifictitle'] does not exist, which is what you needed, if I understood correctly

How to identify a Specific WebElement which is a child of WebTable in UFT

I have a WebTable, which has some WebElements. I want to verify the text of one of the WebElements and take action on it. Can you help, how to proceed on this?
As Vinoth said if you know which row and column the element is in you can use ChildItem.
Typically UFT flattens the elements (so that a WebElement in a WebTable will appear as the WebTables sibling if both are added to the repository. However something that many people do not know is that if you manually put an element under the WebTable (or any other element) then UFT will look for it under the parent object.
This means that you can describe the nested element and UFT will only look under the table and not in the rest of the page.
Browser("B").Page("P").WebTable("T").WebElement("innertext:=.*bla.*").Click
You can use ChildItem method of WebTable.
Set MyWebElement = Browser("CreationTime:=0").Page("micclass:=Page").Webtable("name=TableName").ChildItem(Row, Column, micclass, Index)
Row - Required. A long integer value.
The row number where the cell is located. The first row in the table is numbered 1.
Column - Required. A long integer value.
The column number where the cell is located. The first column in the table is numbered 1.
MicClass - Required. A String value.
The object type.
Index - Required. A long integer value.
The index of the object of type MicClass in the cell. This index indicates the desired element when there is more then one object of type MicClass in the cell. The first object has an index of 0.
MyWebElement is the element you wanted. You can access any methods/properties of WebElement. For ex, to click,
MyWebElement.Click

Resources