Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

ElementArrayFinder.prototype.count is slow since 2.0.0 #2359

Closed
Droogans opened this issue Jul 19, 2015 · 4 comments
Closed

ElementArrayFinder.prototype.count is slow since 2.0.0 #2359

Droogans opened this issue Jul 19, 2015 · 4 comments

Comments

@Droogans
Copy link

Since 2a765c7 was included, I've seen a test that used to take 2 seconds now take almost 11.

This is the test.

it('should have 182 rows in the table', function () {
    expect(element.all(by.repeater('r in rows')).count()).to.eventually.equal(182);
});

The output from the Selenium server in version 2.1.0.

15:54:13.774 INFO - Executing: [is enabled: 0 [org.openqa.selenium.remote.RemoteWebElement@8dadb1bd -> unknown locator]])
15:54:13.782 INFO - Done: [is enabled: 0 [org.openqa.selenium.remote.RemoteWebElement@8dadb1bd -> unknown locator]]
15:54:13.786 INFO - Executing: [is enabled: 1 [org.openqa.selenium.remote.RemoteWebElement@f05f4f94 -> unknown locator]])
15:54:13.854 INFO - Done: [is enabled: 1 [org.openqa.selenium.remote.RemoteWebElement@f05f4f94 -> unknown locator]]
15:54:13.857 INFO - Executing: [is enabled: 2 [org.openqa.selenium.remote.RemoteWebElement@f2f33543 -> unknown locator]])
15:54:13.912 INFO - Done: [is enabled: 2 [org.openqa.selenium.remote.RemoteWebElement@f2f33543 -> unknown locator]]
15:54:13.915 INFO - Executing: [is enabled: 3 [org.openqa.selenium.remote.RemoteWebElement@cfff877 -> unknown locator]])
15:54:13.965 INFO - Done: [is enabled: 3 [org.openqa.selenium.remote.RemoteWebElement@cfff877 -> unknown locator]]
15:54:13.968 INFO - Executing: [is enabled: 4 [org.openqa.selenium.remote.RemoteWebElement@f8780d1a -> unknown locator]])
15:54:14.027 INFO - Done: [is enabled: 4 [org.openqa.selenium.remote.RemoteWebElement@f8780d1a -> unknown locator]]
15:54:14.030 INFO - Executing: [is enabled: 5 [org.openqa.selenium.remote.RemoteWebElement@e87b795b -> unknown locator]])
15:54:14.077 INFO - Done: [is enabled: 5 [org.openqa.selenium.remote.RemoteWebElement@e87b795b -> unknown locator]]
15:54:14.081 INFO - Executing: [is enabled: 6 [org.openqa.selenium.remote.RemoteWebElement@a47d2d50 -> unknown locator]])
15:54:14.127 INFO - Done: [is enabled: 6 [org.openqa.selenium.remote.RemoteWebElement@a47d2d50 -> unknown locator]]
15:54:14.130 INFO - Executing: [is enabled: 7 [org.openqa.selenium.remote.RemoteWebElement@ff6d7067 -> unknown locator]])
15:54:14.179 INFO - Done: [is enabled: 7 [org.openqa.selenium.remote.RemoteWebElement@ff6d7067 -> unknown locator]]

This continues until it reaches the end of the repeater.

Here's my webdriver-manager output on startup.

selenium standalone is up to date.
chromedriver is up to date.
seleniumProcess.pid: 55988
16:25:53.808 INFO - Launching a standalone server
Setting system property webdriver.chrome.driver to /Users/droogans/code/js/encore-ui/node_modules/protractor/selenium/chromedriver
16:25:53.851 INFO - Java: Oracle Corporation 25.45-b02
16:25:53.852 INFO - OS: Mac OS X 10.10.4 x86_64
16:25:53.863 INFO - v2.45.0, with Core v2.45.0. Built from revision 5017cb8
16:25:53.949 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match with current platform: MAC
16:25:53.982 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
16:25:53.983 INFO - Version Jetty/5.1.x
16:25:53.984 INFO - Started HttpContext[/selenium-server,/selenium-server]
16:25:54.018 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@d7b1517
16:25:54.018 INFO - Started HttpContext[/wd,/wd]
16:25:54.018 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
16:25:54.018 INFO - Started HttpContext[/,/]
16:25:54.023 INFO - Started SocketListener on 0.0.0.0:4444
16:25:54.024 INFO - Started org.openqa.jetty.jetty.Server@7cd84586

I'm using firefox version 35 to run these tests. Using ChromeDriver 2.15.322455 (ae8db840dac8d0c453355d3d922c91adfb61df8f) outputs the same logs, but runs much faster at just over 3 seconds.

@sjelin
Copy link
Contributor

sjelin commented Jul 20, 2015

Thanks for the report, but it's not clear if we can do anything. This sounds like an issue with FireFox driver, which would be out of our control.

@Droogans
Copy link
Author

I made a comment on 2a765c7#commitcomment-12254207 for an idea of what I think the problem might be.

Why check if the list has stale elements when counting? Why not expect the user to ask for a new ElementArrayFinder every time? The way the unit test was written implies that protractor will double check your side effects for you.

@hankduan
Copy link
Contributor

Thanks @Droogans. This should help: #2364

hankduan added a commit that referenced this issue Jul 21, 2015
The bug fix for #1903
(2a765c7)
was causing ElementArrayFinder.prototype.count to be slow because of
the extranous checks that must be performed. However, the checks could be
delayed into the isPresent check, which will mitigate this issue

fixes(#2359)
@hankduan
Copy link
Contributor

fixed with #2364

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants