i know i am doing something wrong here but i would like your help on this one
i have this html code
<span id='some text'>some text</span>
<ul> this is what I would like to grab </ul>
<span id='some more text'>some more text</span>
so i tried something and since this is the first time i am working with xpath i was quite sure i was doing wrong.
driver.find_elements_by_xpath('//ul[preceding:://span[@id="some text"] and following:://span[@id="some more text"] ')
any help is appreciated
1 Answer 1
An id attribute is supposed to be unique, so one is enough to select a branch.
To get the <ul> tag following the <span id='some text'>:
driver.find_elements_by_xpath("//span[@id='some text']/following-sibling::ul[1]")
, and with a CSS selector:
driver.find_elements_by_css_selector("span[id='some text'] + ul")
answered Jul 29, 2017 at 22:35
Florent B.
42.7k7 gold badges92 silver badges105 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
jan deeg
wow thanks that totally worked. i wasn't expecting an answer this quick
default