S. Roelofsen
S. Roelofsen

Reputation: 11

Nightwatch & Selenium | Testing if an element contains text with a single quote

I'm testing if an element contains text with a single quote in it. I tried :

'PROGRAMMA\'S' or "PROGRAMMA'S", like .assert.containsText('element', 'PROGRAMMA\'S')

Both ways aren't working. Nightwatch gives back :

Testing if element <.menu > li:nth-child(2) a> contains text: "PROGRAMMA'S". - expected "PROGRAMMA'S" but got: PROGRAMMA'S

Upvotes: 1

Views: 1607

Answers (1)

QualiT
QualiT

Reputation: 1955

Have you tried it without escaping the apostrophe? .assert.containsText('element', "PROGRAMMA'S")

In figuring out why this isn't working I'd check that the apostrophe char is of the type I'm looking for (and not an html entity or whatever: &lsquo; &rsquo; &#8216; &#8217;' or &apos;). Since containsText does not require an exact match, you could also also just search on PROGRAMMA unless there is some reason the apostrophe and the 's' are important to it being a valid test.

Upvotes: 1

Related Questions