CodePudding user response:
The following XPath will give exactly what you need:
"//span[text()='by ']/following-sibling::*[1]"
There are several points to be improved in your initial XPath:
//span[contains(text(),"by")]
matches more than 16 relevant elements./following-sibling::*
selects All the following siblings, of any tag name. But this selects all the following siblings, not only adjacent following siblings. To make this precise[1]
index added.