Skip to content

Commit

Permalink
Normalising the space while getting the elements using xpath #44
Browse files Browse the repository at this point in the history
  • Loading branch information
Apoorva-GA committed Jul 17, 2018
1 parent 880bc99 commit 6966ef4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/taiko.js
Expand Up @@ -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}"` };
};

Expand Down Expand Up @@ -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}"` };
Expand Down

0 comments on commit 6966ef4

Please sign in to comment.