cancel
Showing results for 
Search instead for 
Did you mean: 

How to identify HTML button with a relative xPath

fabio_a_carvalh
Level 2
Hello, I am not being able to identify an HTML element in an effective way. The only way I can identify it in Application Modeler is using the "Path", and when I uncheck it I cannot anymore Highlight this element, even when the other attributes would in theory be enough. It would work but it happens that the page is dynamic and the button can in some situations be in a different path. I have tried to change the "Path" "Math Type" to Wildcard and reg ex but I get an error. example path: /HTML/FRAMESET(1)/FRAME(4)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(2)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(1)/HTML/BODY(1)/FORM(1)/TABLE(3)/TBODY(1)/TR(1)/TD(1)/BUTTON(1) My question is, how can I identify this button? Is is possible to use xPath in a relative way? Can we actually use xPath in Blue Prism? Lets say like //button[@title='my search button'] Thank you in advance Fabio
5 REPLIES 5

ShreyansNahar
Level 5
Hi, If the xPath of the button keeps on changing every time you open the web link/app, it might be a difficult task to detect that button. Still, a way around could be to spy the different locations of the button using HTML mode and compare the xPaths of each. You will find that there will be a specific value that changes every time in the xPath. For example, if following are the xPaths from different location, then you can proceed to make the changing value dynamic. /HTML/FRAMESET(1)/FRAME(4)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(2)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(1)/HTML/BODY(1)/FORM(1)/TABLE(3)/TBODY(1)/TR(1)/TD(1)/BUTTON(1) /HTML/FRAMESET(1)/FRAME(4)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(2)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(1)/HTML/BODY(1)/FORM(1)/TABLE(3)/TBODY(1)/TR(2)/TD(1)/BUTTON(1) /HTML/FRAMESET(1)/FRAME(4)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(2)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(1)/HTML/BODY(1)/FORM(1)/TABLE(3)/TBODY(1)/TR(4)/TD(1)/BUTTON(1) Your dynamic xPath should be stored in a data item xPath with value as /HTML/FRAMESET(1)/FRAME(4)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(2)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(1)/HTML/BODY(1)/FORM(1)/TABLE(3)/TBODY(1)/TR(@id)/TD(1)/BUTTON(1). Next, start with an count =1, and in Calculation stage, use the Replace function as Replace(xPath, ""@id"", count). Then try to perform action on the item using the updated xPath. If you cannot find the correct one, move to the next value and continue doing the same till you find the one required. Hope this helps.

Thanks for your reply Nahar What I can't understand is how then the Application Modeller can use this generated path from a calculation? Is it that Blue Prism does not support xPath like //button[@title='my search button'] like for example tools that interact with the web applications in a similar way do, like Selenium? Is there a bug on Blue Prism that we cannot use reg ex and wildcards with paths? (basically Nahar suggestion is a workaround to this) (Would be interesting to have an answer from someone from Blue Prism on this) Regards, and thanks in advance Fabio

ShreyansNahar
Level 5
You need to identify only a single element and then instead of ""equal to"" use ""dynamic"". And then in the Params field, use the data item with the edited value as explained above. BP does support xPaths such as /HTML/FRAMESET(1)/FRAME(4)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(2)/HTML/FRAMESET(1)/FRAMESET(1)/FRAME(1)/HTML/BODY(1)/FORM(1)/TABLE(3)/TBODY(1)/TR(1)/TD(1)/BUTTON(1). I am not sure about paths like //button[@title='my search button']. In the former method, BP does not have bugs about using reg ex and wildcards with paths.

adrian_pruteanu
Level 2
Actually I encounter kind of the same problem in trying to use wildcards with the Path attribute. For instance, in this page http://www.locatefamily.com/Street-Lists/Romania/VASLUI/BARLAD/index22 I want to find in the column NAME people called ""Nedelcu"", for instance (name is variable from one instance to another). So my approach was to identify the HTML path of that column in tha table and than add another dynamic attribute regarding the name. As you don't know upfront the line on which you will find the person the attributes were set like this: Path Wildcard /HTML/BODY(1)/DIV(4)/DIV(1)/DIV(1)/DIV(1)/TABLE(1)/TBODY(1)/TR(*)/TD(3)/A(1) - the TR() is the variable that handles the line Value Dynamic Nedelcu - that's fed from a data item But it doesn't work when I switch to from equal to wildcard on the Path attribute, it doesn'f find anything. If instead of wildcard I use equal (and put the row number) it works every time. So how can you use the Path attribute with wildcards? Am I doing something wrong or is it not possible at all? Tks, PS: I have a workarround in my mind, didn't test it, but I think it can work - to use dynamic attribute on Path and go through each line, 1 by 1, and match the results with the Surname value, but this seem not to be the most elegant version. Plus I really need to know how things work with wildcards in the Path attribute, cos I'll be needing it a lot in the future.

Denis__Dennehy
Level 15
Hello, as you have found the HTML Path does not accept wildcards. It is a precise value route/path through the HTML to a single point, if there was a wildcard then logic would be required to search all routes from the point of the wildcard onwards. (So for your example it would needs to search all TR(*) routes forward - such as TR(1) TR(2) TR(3) etc, where multiple elements could quite rightly exist that match that criteria. To do what you suggest you could build your flow to increment the * value and try to find the element multiple times until it is found - so for your example your flow logic would try to use /HTML/BODY(1)/DIV(4)/DIV(1)/DIV(1)/DIV(1)/TABLE(1)/TBODY(1)/TR(1)/TD(3)/A(1) then /HTML/BODY(1)/DIV(4)/DIV(1)/DIV(1)/DIV(1)/TABLE(1)/TBODY(1)/TR(2)/TD(3)/A(1) etc until the element is found and used. A more common use is that the element value is set based upon the path of a nearby value. So you use Get HTML Path in a read stage for a text label (without using the path), and use that to dynamically calculate the path of all nearby elements.