I am trying to escape an apostrophe in Selenium. Sample text below
<a title="My Day's Schedule"></a>
//a[contains(@title , 'My Day's Schedule')]
Use a back-slash like
\ before the sign you want to escape.
If you sometimes don't want so escape to much you can also use part of the attributes like:
//a[contains(@title, 's Schedule')]
Or with escape:
//a[@title='My Day\'s Schedule']
As an alternative you can also use other attributes like
href instead of
Tip: use contains only when give part of the string, else use @attribute='string'