The URL is enter link description here
Is there any way in selenium XPath to get value the element just the element which following sibling of located element
//span[contains(text(),"by")]//following-sibling::a
in this code I want to take the next element because sometimes it is not an anchor tag but span
For getting values of Author I am using the way, searching for "by" word element then
x_authors=driver.find_elements(By.XPATH,'//span[contains(text(),"by")]//following-sibling::a')
x_authors_a=driver.find_elements(By.XPATH,'//span[contains(text(),"by")]//following-sibling::span[1]')


a, and the case where it's aspan.//is shorthand for/descendant-or-self::node()/, that makes your full XPath//span[contains(text(),"by")]/descendant-or-self::node()/following-sibling::awhich selects anyaelements which follow sibling elements which are eitherspanelements containing 'by', or descendants of aspancontaining 'by'.//following-siblig::ashould give any elementspanora? But even in inspect mode it gives//span[contains(text(),"by")]//following-sibling::aonly 10 there should be 16//span[contains(text(),"by")]//following-sibling::a or following-sibling::spanfollowing-sibling::acan only returnaelements and will never return aspanelement