the expression seems to be incorrect as the part


looks like does not fulfill the regular xpath pattern. If this works, it is a nice XPath hack.
If I would like to select neighbors of the “SELENIUM” element on the page , I would use the following XPath:

//h2[contains(.,"A few of our most popular courses")/parent::div[@class="rt-grid-12 rt-alpha rt-omega"]//div[@class='rt-grid-2 rt-omega']

but this will select all descendants of the grid, including the “SELENIUM” element … and this is not exactly what was required in the example. But it is more likely what you will really need.

So looks like the formula in the example is selecting the div, which has a descendant with text “SELENIUM” and from that, all the following siblings due to // before the div and through so-called “XPath recursion” with [//a[text()='SELENIUM']].
I personally did not see such use of XPath before and I hope I would not need it in the future. But at least it is good to know, that it could work that way.

Source link


Please enter your comment!
Please enter your name here