Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting this error "The selector "[text()="Logout"]" used with strategy "css selector" is invalid!"

While running below code, getting this error in webdriverio. please help me to solve this.

Error thrown:
"The selector "[text()="Logout"]" used with strategy "css selector" is invalid!"

code snippet:
const logout = await $(‘[text()="Logout"]’)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This is how the tag looks

>Solution :

You are trying to use an XPath expression with a CSS selector. The text() function is not a valid CSS selector.

This will find an a element with the text “Logout”.

const logout = await $('//a[text()="Logout"]')

In an XPath expression, //a selects all a elements in the document, regardless of their location.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading