I need to confirm the visibility of a tooltip popup by using the
window.getComputedStyle().visibility
property with Protractor framework.
When I provide a string to the executeScript
function, everything works correctly. It returns visible
:
// elementToCheck is an ElementFinder
async getComputedStyleVisibility(elementToCheck) {
return await browser
.executeScript(`return window.getComputedStyle(document.querySelector('${elementToCheck.locator().value}')).visibility`);
}
However, the issue arises when I try replacing the string in the executeScript
with a function. It now returns hidden
and seems to get stuck until the tooltip popup disappears.
It appears there may be a synchronization problem, but I'm having trouble pinpointing the exact cause:
// elementToCheck is an ElementFinder
async getComputedStyleVisibility(elementToCheck) {
return await browser.executeScript(
webElem => (window.getComputedStyle(webElem).visibility),
await elementToCheck.getWebElement()
);
}