Sarvesh Singh
Sarvesh Singh

Reputation: 51

Not able to select element using XPath

<div data-v-1dac319c="" class="ca-modal-header">
<span data-v-1dac319c="" class="ca-modal-header-title">New Claim Attachment</span> 
<button data-v-1dac319c="" class="ca-modal-close material-icons">close </button>
</div>

I am unable to select the Close button using XPath. Following is not working - //span[text()='New Claim Attachment']/following-sibling::button[text()='close']

Upvotes: 0

Views: 105

Answers (2)

Prophet
Prophet

Reputation: 33361

You can use this XPath:

//span[text()='New Claim Attachment']/..//button[contains(text(),'close')]

Or this:

//div[.//span[text()='New Claim Attachment']]//button[contains,text()'close')]

Upvotes: 1

gangabass
gangabass

Reputation: 10666

Your XPath expression doesn't work because you have a small space at the end of your close . contains should work:

//span[text()='New Claim Attachment']/following-sibling::button[contains(., 'close')]

Upvotes: 1

Related Questions