Skip to content

Commit

Permalink
Merge pull request #259 from getgauge/258_fix_contains
Browse files Browse the repository at this point in the history
Fix contains to get the innermost element
  • Loading branch information
Apoorva-GA committed Nov 13, 2018
2 parents 6fcbd84 + d17862b commit d4c1a45
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/taiko.js
Expand Up @@ -1320,7 +1320,7 @@ function contains(text, ...args) {
assertType(text);
const get = async (e = '*') => {
let elements = await $$xpath('//' + e + `[contains(@value, ${xpath(text)})]`);
if (!elements || !elements.length) elements = await $$xpath('//' + e + `[not(descendant::div) and contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'), ${xpath(text.toLowerCase())})]`);
if (!elements || !elements.length) elements = await $$xpath('//' + e + `[not(descendant::*[contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'), ${xpath(text.toLowerCase())})]) and contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'), ${xpath(text.toLowerCase())})]`);
return await handleRelativeSearch(elements, args);
};
return { get: getIfExists(get), exists: exists(getIfExists(get)), description: `Element containing text "${text}"`, text: selectorText(get) };
Expand Down

0 comments on commit d4c1a45

Please sign in to comment.