Reputation: 3836
In some application there are div's with custom tip attribute:
<div tip="<b>Kobold łucznik</b>" style="left: 450px; top: 220px;">...</div>
<div tip="<b>Kobold łucznik</b>" style="left: 320px; top: 320px;">...</div>
I'm using nodeJs selenium webdriver to pull some data from this application. I found info that I can use xpath to grab elements which attribute is equal to something.
What I want to achieve is find all elements which value of custom attribute tip contain string: 'Kobold łucznik'
. I want to do that to be able to collect x and y from left: x px
and top: y px
and push it to some array of objects later on.
But the first step is to find all this elements.
I tried like this:
driver.findElements(webdriver.By.xpath('//@*[contains('Kobold łucznik','tip')]/..'))
But with no luck.
As @zx485 said in comment section the issue here is that tip
attribute value has <
in it. Unfortunately I can not change the tip
value. The key for my app to work correctly is to grab those elements and I can not get the job done without doing it.
Upvotes: 0
Views: 2295
Reputation: 497
I think this should work
driver.findElements(By.xpath("//div[contains(@tip,'Kobold łucznik')]")
or use css selector which fast and compatible with more browser
driver.findElements(By.css("div[tip*='Kobold łucznik']"))
Upvotes: 3