Text of anchor tag & parent list tag

Hi,

I have to write a script wherein inside the list tag, there’s one anchor tag & one div tag…the anchor tag¬†¬†contains some text, whereas the parent list tag also contains some text. I need to get text of inline anchor element as well as text of list tag separately.

 

Here’s the HTML:

<li>
<a class=”identifier” href=”/ICD10CM/Codes/A00-B99″>A00-B99</a> <div data-titledivname=”z1″ data-textdivname=”x1″ class=”tip images-note” data-hasqtip=”0″></div> Certain infectious and parasitic diseases
</li>

 

So, I want to get ‘A00-B99’ and ‘Certain infectious….’ both texts in double-quotes

Default Asked on March 7, 2018 in Selenium WebDriver.

Are the identifiers unique?

You could use an XPath like

//a[@class=’identifier’]/text()

to grab the “A00-B99”. If you need to base it on the identifiers in the <div> element, you could try

//div[@data-titledivname=’z1′]/../a/text()

which should give the “A00-B99” and

//div[@data-titledivname=’z1′]/../text()

which should grab “Certain infectious…”. You may need to use indexes (add [1] or [2], etc.) because I’m not positive the second one won’t give you “A00-B99Certain infectious…”

 

roger

on March 7, 2018.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.