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"]’)
>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.