23 Apr '13, 2am

XPath kind of sucks, but you'd think it might be good at the one thing it was designed for. But no:

I’m writing Selenium tests again, which means a lot of XPath. Here’s a trick I learned thanks to this article on Push Button Paradise. The problem is, how do you write XPath that matches one class in a multi-class element like <div class='foo bar'> ? The standard XPath equality operator matches a full string, so //div[@class='foo'] won’t work. The solution is arcane but I promise it works: //div[contains(concat(' ',normalize-space(@class),' '),' foo ')] Note that there must be spaces on either side of the class name ‘foo’. Since this is quite a mouthful, I’ve extracted it into a helper method. Here it is in Java: /** * Generates a partial xpath expression that matches an element whose 'class' attribute * contains the given CSS className. So to match &lt;div class='foo bar'&gt; you would * say "//div[" + containingClass("foo") + "]". * * @param className CSS class name * @r...

Full article: http://pivotallabs.com/xpath-css-class-matching/

Tweets

Now Hiring for a Sr. IT Support Engineer in SF!...

pivotallabs.com 23 Apr '13, 8pm

Sr. IT Support Engineer San Francisco A human being should be able to change a diaper, plan an invasion, butcher a hog, co...

How the @USArmy's #learning cloud means accessible class materials (via @defense_news) CC: @BlackboardProEd

How the @USArmy's #learning cloud means accessi...

defensenews.com 23 Apr '13, 12am

Army learning institutions are making course materials that were once hidden behind online firewalls more accessible, on s...

Be helpful, be kind or be quiet

Be helpful, be kind or be quiet

raventools.com 16 Apr '13, 6pm

Something horrible happened yesterday in America. In the midst of the blood and terror, there were the heros we all hoped ...