'XPath for all elements with any attribute with specific value?
I am using Selenium to identify any HTML element that may have a specified value in any of its attributes. I was hoping that there would be some way in XPath to do this, but I haven't been able to find any answers yet.
Solution 1:[1]
Here are XPath expressions for selecting...
All elements:
//*All elements with an attribute,
a://*[@a]All elements with an attribute
aequal tov://*[@a='v']All elements with any attribute:
//*[@*]All elements with any attribute equal to
v://*[@*='v']
Credit to @Pierre for first posting //*[@*='v'].
Solution 2:[2]
//*[@*[contains(.,'val')]]
Will find any descendant node from the root with any attribute containing 'val' in its value.
Solution 3:[3]
Thanks Guys!! I tried this on XPathFiddle and it seems to work:
Sample HTML:
<html>
<body>
<div my-attr1='value1'>
<a>
<span my-attr2='value2'> Some Link </span>
</a>
</div>
<span my-attr3='value1'> Some Text </span>
</body>
</html>
Sample XPath : html//*[@*='value1']
The XPath above, selects the div with my-attr1 and the span with my-attr3.
Solution 4:[4]
//a[@href[contains(.,'mailto:')]]
This path will find all a tags with href attribute contains "mailto:" string
Solution 5:[5]
We had the same problem. We solved it by manually performing some steps of the maven plugin:
- Go to the solidity versions list posted here: https://internal.services.web3labs.com/api/solidity/versions/.
- Save the displayed json as
releases.jsonin~/.web3j/solc/. - Manually search the list of binaries download the one you need (i.e. win/linux/mac).
- Save the selected binary in a subfolder using the version as its name. For example, if you need version
0.4.25create a corresponding folder (~/.web3j/solc/0.4.25/) and put the binaries there. - Rerun your maven build.
Somehow, the problem is that the maven plugin is not able to download the corresponding files. After doing that manually, the plugin finds the binaries and skips downloading them.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bender the Greatest |
| Solution 2 | Shlomi Uziel |
| Solution 3 | |
| Solution 4 | Johnny |
| Solution 5 | lukas |
