I am tryining to find the following element in the DOM using selenium
<button>
App\u00ADly
</button>
As you can see there is a soft hyphen character between the word Apply I am wondering if there is any way to ignore this character and make that the following Xpath works.
//button[text()='Apply']
Thanks in advance.
CodePudding user response:
I believe the text \u00AD
is dynamic or you want to skip. You can use contains
in xPath
along with and
condition.
//button[contains(text(),'App') and contains(text(),'ly')]
CodePudding user response:
contains
is wrongly used in lot of places. There are more xpath function such as starts-with
and ends-with
(xpath v2.0).
But since selenium is tagged which uses xpath v1.0
you won't be able to use ends-with
You can try something like :
//input[starts-with(text(),'App') and contains(text(),'ly')]