30-07-19 12:46 PM
Hi all,
I am currently building an integration where the usage of Dynamic Attributes with wildcards would be a huge help.
Is there any way to achieve this?
For example:
The Window Text of a specific window can be:
"Create - Customer", "Create - Product", "Modify - Customer", "Modify - Product" and so on.
If I could provide "Create*" or "Modify*", through the Dynamic input, that would solve the issue - But I cant seem to find a way to trigger the wildcard search, through the dynamic input.
I do have other solutions in mind, but this would be the easiest and cleanest, if possible.
14-10-22 04:49 PM
Thank you for the reply .
I am attaching you the rows which I should catch(There may be one 1 row ,3,9 rows etc . )
14-10-22 05:42 PM
15-10-22 01:31 AM
Hi @ErjolaMema,
If you can also show the table tag above, it that would be helpful. From what you showed me, seems like you have a table, and you want to catch the values within each of the td tag corresponding to the cells of different rows but for the same column.
Problem Statement:
In my example, let's say I have a requirement where I need to extract only the cell value for each of the cells in the first column which is called as 'Name' as shown below:
In your case you too have a similar requirement where you want to extract the values for each cell with the column header as 'Conto'
Solution Explanation:
If, you see the HTML structure, on a very high level, we have a table tag with an id attribute called as 'example' which consists of a thead and a tbody section as shown below:
Now if I see thead section, it has all my header cells denoted within separate th tag here:
And similarly, my tbody tag will have different rows denoted by tr tag within which each cell will be denoted by td tag:
So the XPath Expression that I am going to build for this use case would be something like this: //table[@id='example']//tbody/tr[1]/td[1]
What it means essentially in layman's term is go the table tag with the id attribute as 'example' first. Once you find it, go inside the table for the tbody tag and within that aim for row number 1 which denoted by tr[1] and column number 1 which is denoted by td[1]
This XPath would always aim to 1st row and 1 column value as shown below:
Now if let say I want to make it a bit more robust such as I give the name of the column and it automatically provides the value irrespective of the position of the column, my tweaked XPath expression would become: //table[@id='example']//tbody/tr[1]/td[count(//table/thead/tr/th[.="Name"]/preceding-sibling::th)+1]
Here instead of td[1] I wrote td[count(//table/thead/tr/th[.="Name"]/preceding-sibling::th)+1]
which means find one position ahead of the position of the td tag which corresponds to the column defined just before the column having the header title as 'Name' within the thead section of the table.
What this does is it makes your XPath expression dynamic, and it won't rely on column position. Now to finally complete our XPath query we would make the expression dynamic in such a way that we can keep looping a counter variable within it for the tr tag as we are right now pointing the expression to first row using tr[1].
So, we make the attribute dynamic in nature and we use the following expression in a read stage:
The final expression becomes:
"//table[@id='example']//tbody/tr["& [row counter] &"]/td[count(//table/thead/tr/th[.=""Name""]/preceding-sibling::th)+1]"
Final Solution:
So you can use the following modified final expression which I have simplified even further than what I used for my explanation. The only condition is that your table must have a th tag with the name as 'Conto' and a data item called row counter which start from 1 and keeps incrementing till it encounters an error to exit:
"//table[@id='example']//tr["& [row counter] &"]/td[count(//table//th[.=""Conto""]/preceding-sibling::th)+1]"
Also, the best thing about this is if you are able to provide an attribute to the table tag which is 'id' in my case then you probably don't even need to worry about the DIV tags behind it as it will straightaway search from table table ignoring the DIV tag values which you were facing initially.
NOTE: Remember to change the table id tag here from example to what you have. If you don't have id attribute look for a unique attribute and replace both id attribute with that and its value as well
17-10-22 09:16 AM
Hi Devneet ,
Thank you very much for the reply.
Attached is the table :
17-10-22 09:36 AM
Hi Devneet ,
The other thing is that I have it only Web Path ,not also the X Path .
Is it a problem?
17-10-22 09:38 AM
Hi @AmiBarrett,
I don't have the Xpath in it .
Is there any other way for a solution ?
17-10-22 11:17 AM
17-10-22 11:28 AM
17-10-22 05:25 PM