taiko
taiko copied to clipboard
isVisible() is always returning false when used along with text("<text_of_a_element>")
Describe the bug
isVisible() is always returning false when used along with text("<text_of_a_element>").
await highlight(text("<text_of_a_element>")); is highlighting the element but isVisible() is returning false, if we use a selector like $, button, link etc then we are getting the expected result.
To Reproduce Script to reproduce the behavior:
(async () => {
try {
await openBrowser();
await goto("Google.com");
await highlight(text("India"));
await console.log(await text("India").isVisible());
} catch (error) {
console.error(error);
} finally {
await closeBrowser();
}
})();
Expected behavior
isVisible() Should return true since the text is available and visible on the page.
Versions:
- Taiko: 1.4.3
- OS: MAC Os 12.4
- Node.js: v14.19.1
Additional context
The below code snippet is working fine with $ instead of text
(async () => {
try {
await openBrowser();
await goto("Google.com");
await highlight(text("India"));
await console.log(await $("//DIV[text()='India']").isVisible());
} catch (error) {
console.error(error);
} finally {
await closeBrowser();
}
})();
It looks like it may be a regression introduced by https://github.com/getgauge/taiko/pull/2288
@gokultw I have had the same issue while using Taiko. The problem in my case was that isVisible()returned false when the element I was looking for existed multiple times on the page. So this would be my first guess that the text India is found multiple times on the page but that the Xpath "//DIV[text()='India']" is unique and therefore isVisible() works correctly.