diff --git a/lib/taiko.js b/lib/taiko.js index 240d11497..ef0bbc710 100644 --- a/lib/taiko.js +++ b/lib/taiko.js @@ -839,7 +839,7 @@ module.exports.radioButton = (attribute,value, ...args) => { module.exports.text = (text, ...args) => { validate(); assertType(text); - const get = async (e = '*') => await handleRelativeSearch(await $$xpath('//' + e + `[text()=${xpath(text)}]`), args); + const get = async (e = '*') => await handleRelativeSearch(await $$xpath('//' + e + `[normalize-space(text())=${xpath(text)}]`), args); return { get: get, exists: exists(get), description: `Element with text "${text}"` }; }; @@ -871,7 +871,7 @@ function match(text, ...args) { assertType(text); const get = async (e = '*') => { let elements = await $$xpath('//' + e + `[@value=${xpath(text)}]`); - if (!elements || !elements.length) elements = await $$xpath('//' + e + `[text()=${xpath(text)}]`); + if (!elements || !elements.length) elements = await $$xpath('//' + e + `[normalize-space(text())=${xpath(text)}]`); return await handleRelativeSearch(elements, args); }; return { get: get, exists: exists(get), description: `Element matching text "${text}"` };