XPath to an icon?

Hi everyone!

I have yet another easy question.

There’s an icon on the website that is dynamically changing to be white or yellow and I need RPA to figure out which one there is.

So far I’m using the visualGetPixelColor function and it works great, but it is somewhat slow and takes about 2 seconds to execute. I had a lot of these visual functions in my macro at the beginning but now I’m transferring all that to storeText, because it’s so much faster and doesn’t depend on the correct page scroll.

Anyways, here’s the element code for when the white icon is present:

<body>
   - some dynamic content that's always different -
   <div>
      <div id=cars>
   <div>
     <svg class="a-icon a-icon--setActive a-icon--transparentSec>
   <div>
      <span>

And here the code of the yellow icon:

<body>
   - some dynamic content that's always different -
   <div>
      <div id=cars>
   <div>
     <svg class="a-icon a-icon--setOrange a-icon--setOrangeSec>
   <div>
      <span>

So as you can see there’s the SVG class and then a couple of words that change. Like the setActive to setOrange.

All I need is a variable that reads the text after the “SVG” class and stores it into a string. Then I do some javascript commands to figure out whether it says orange or transparent and I’m good. But what I’m struggling with is to get the variable.

I tried to use the storeText on the SVG element, but I’m getting only an empty variable. I also found there’s a sourceExtract command but I’m not really sure how to use it.

So if there’s anyone who knows how to get it would be great.

By the way, I think the anchor here should be the div “cars”, because otherwise there are a lot of instances of this same icon on the website and I need only that one under the cars section.

Thanks a lot!

Did you try storeAttribute?

Or if that fails, then sourceSearch?

storeAttribute gives me only LNF.

As for the srouceSearch, same as with sourceExtract, I’m not really sure how to use it. It doesn’t accept the usual XPath, only the regex. So if anyone could write the correct regex for me based on the code I wrote above would be very helpful.

For anyone who finds this thread and has the same question, sourceExtract is indeed the way to go here. What helps in this matter are the special regex characters used to look behind (?<=) and look ahead (?=). This enables you to capture exactly the portion of the code between two always-present elements of the web. The dynamic part of the web stored inside the variable by the sourceExtract can then be worked on by the usual Javascript in the executeScript_Sandbox command to get you exactly what you want.

Here’s a thread that gave me the right pointer: