Sandeep Dhamale
Sandeep Dhamale

Reputation: 499

Create XPath for button with text

enter image description here

I tried with following but no luck.

//button[contains(text(),'Upload')]

Upvotes: 2

Views: 5898

Answers (1)

JLRishe
JLRishe

Reputation: 101758

The XPath //button[contains(text(),'Upload')] will match a button whose first child text node contains "Upload".

It's not clear from your screenshot, but there may be an all-whitespace text node before the <span>, and if so, it would not contain "Upload".

Instead, try:

//button[contains(., 'Upload')]

Upvotes: 4

Related Questions