CodeceptJs : element not found with certains characters

484 views Asked by At

I'm using CodeceptsJs 2.0.4 and Gherkin 5.1.0 to test my app.

I have an issue with an xpath expression. When searched text contains " :" or " ?" characters, the CodeceptJs function waitForElement doesn't find the element.

For example, I'm looking for element <a>Some blabla : blablablabla.</a> :

I.waitForElement(".//div[@class = 'myCLass']//a[contains(., 'Some blabla : blablablabla.')]", 60)
I.waitForElement(".//div[@class = 'myCLass']//a[contains(., 'Some blabla ')]", 60)

-> Both elements are not found

But with :

I.waitForElement(".//div[@class = 'myCLass']//a[contains(., 'Some blabla')]", 60)
I.waitForElement(".//div[@class = 'myCLass']//a[contains(., ': blablablabla.')]", 60)

-> Both elements are found

You can test it with $x(xpath) function available in browsers

Thanks for your help !

1

There are 1 answers

1
elind On BEST ANSWER

Does browser finds your element? And what exactly you want to achieve, find element which contains some text, or element which has exactly given text? Have you tried '//a[contains(text(), "Some blabla : blablablabla.")]'? Try also '//a[contains(text(), "Some blabla : blablablabla.")]'(but firstly first option, I believe it should work)