Zoran
Zoran

Reputation: 499

Find element contains specific "path" attribute

Can someone please assist with the following issue?

I have map with more than 2000 elements loaded, but only one of them (which is currently visible) has the element 'path' with an attribute d different than zero. For easier understanding, refer to the following screenshot:

enter image description here

Tried with this: SVG & Path finding, but did not find what I was looking for.

And having this XPath:

//div[@id="map"]//div[contains(@class,"map")]//div[@class="leaflet-pane"]//div[@class="leaflet-pane2"]//*[name()='svg']//*[name()='path' and @d="M0 0"]

which finds all of them (2000).

What I am looking for is something like this (though I could not find the correct solution) - deliberately just added end of Xpath.

In summary, I need the d attribute (inside path) to not contain the value zero:

//*[name()='svg']//*[name()='path' and @d(contains,"125")]

Please assist, and thank you in advance.

Upvotes: 1

Views: 508

Answers (1)

Prophet
Prophet

Reputation: 33361

According to your descriptions you are looking for locator where d attribute value is not equals to M0 0.
This can be translated to XPath with not operator.
Please try this:

//div[@id="map"]//div[contains(@class,"map")]//div[@class="leaflet-pane"]//div[@class="leaflet-pane2"]//*[name()='svg']//*[name()='path' and(not(@d="M0 0"))]

Upvotes: 1

Related Questions