Search code examples
testingseleniumselenium-webdriverprotractorend-to-end

protractor expected condition visibilityOf() returns true when element is not displayed


According to protractor's API for visibiityOf(): Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

I have a search page that returns 50 rows of data.The 50th row is at the bottom of the page out of view and can only be seen if you scroll several times to the bottom. How is it possible that this line is completed immediately when I never scroll down?

browser.wait(EC.visibilityOf(element(by.xpath("//*[@id='search-result']/table/tbody/tr[50]/td[1]")), 20000));

the element does exists, it's just that its not in view. So I don't understand what is going on.


Solution

  • This is not actually about the protractor, but more about the Selenium WebDriver and the javascript selenium webdriver bindings (WebDriverJS which is what protractor is wrapping).

    Here is the Selenium WebDriver specification describing what WebDriver is taking into account to determine the visibility (it is not trivial):

    Here is the javascript selenium bindings "displayedness" implementation: