Local functional tests start after more then 1 minute

ぐ巨炮叔叔 提交于 2019-12-07 20:18:09

问题


I have the same tests, the same selenium-server-standalone (2.43.1) and chromedriver (2.10). I have only functional tests (no unit tests). My Chrome is at version 37. My OSX is at version 10.9.5. Java version is 1.7.0_51 (Java 7 update 67).

When I run tests a new Chrome instance is opened with an empty tab:

  • With intern 1.7.0 tests start in less then 10 seconds.
  • With intern 2.1.1 tests start in 55-60 seconds.

Selenium logs look like this (when run by intern 2.1.1):

01:26:50.195 INFO - Launching a standalone server
01:26:50.388 INFO - Java: Oracle Corporation 24.51-b03
01:26:50.388 INFO - OS: Mac OS X 10.9.5 x86_64
01:26:50.487 INFO - v2.43.1, with Core v2.43.1. Built from revision 5163bce
01:26:50.734 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: MAC
01:26:50.846 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
01:26:50.847 INFO - Version Jetty/5.1.x
01:26:50.850 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
01:26:50.851 INFO - Started HttpContext[/selenium-server,/selenium-server]
01:26:50.851 INFO - Started HttpContext[/,/]
01:26:56.063 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@1f8f110d
01:26:56.064 INFO - Started HttpContext[/wd,/wd]
01:26:56.101 INFO - Started SocketListener on 0.0.0.0:4444
01:26:56.101 INFO - Started org.openqa.jetty.jetty.Server@71a9b093
01:27:24.536 INFO - Executing: [new session: Capabilities [{idle-timeout=60, browserName=chrome, name=tests/intern_local, selenium-version=2.43.1, chromeOptions={args=[test-type]}}]])
01:27:24.592 INFO - Creating a new session for Capabilities [{idle-timeout=60, browserName=chrome, name=tests/intern_local, selenium-version=2.43.1, chromeOptions={args=[test-type]}}]
Starting ChromeDriver (v2.10.267517) on port 32601
Only local connections are allowed.
01:27:26.447 INFO - Done: [new session: Capabilities [{idle-timeout=60, browserName=chrome, name=tests/intern_local, selenium-version=2.43.1, chromeOptions={args=[test-type]}}]]
01:27:26.465 INFO - Executing: [get: about:blank])
01:27:26.865 INFO - Done: [get: about:blank]
01:27:26.875 INFO - Executing: [get location context])
01:27:26.876 INFO - Executing: [take screenshot])
01:27:26.876 INFO - Executing: [get local storage size])
01:27:26.876 INFO - Executing: [doubleclick: no args])
01:27:26.878 INFO - Executing: [execute async script: arguments[0](true);, []])
01:27:27.109 INFO - Done: [take screenshot]
01:27:27.114 INFO - Executing: [Long press: null])
01:27:27.154 INFO - Done: [doubleclick: no args]
01:27:27.158 INFO - Executing: [get window size])
01:27:27.169 INFO - Done: [execute async script: arguments[0](true);, []]
01:27:27.169 WARN - Exception thrown
java.lang.UnsupportedOperationException: Underlying driver does not implement advanced user interactions yet.
    at org.openqa.selenium.support.events.EventFiringWebDriver.getTouch(EventFiringWebDriver.java:311)
    at org.openqa.selenium.remote.server.handler.interactions.touch.LongPressOnElement.call(LongPressOnElement.java:40)
    at org.openqa.selenium.remote.server.handler.interactions.touch.LongPressOnElement.call(LongPressOnElement.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
01:27:27.189 WARN - Exception: Underlying driver does not implement advanced user interactions yet.
01:27:27.205 INFO - Done: [get window size]
01:27:27.212 INFO - Executing: [set window size])
01:27:27.323 INFO - Done: [set window size]
01:27:31.956 WARN - Exception thrown
org.openqa.selenium.WebDriverException: unknown error: Location must be set before it can be retrieved
  (Session info: chrome=37.0.2062.124)
  (Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3 milliseconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_51'
Session ID: 25d1fbe63300966edb133612003055d1
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/zx/954mnbfn6s145t6d04g5nr5h0000gq/T/.org.chromium.Chromium.dGVeyG}, rotatable=false, locationContextEnabled=true, version=37.0.2062.124, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:614)
    at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:32)
    at org.openqa.selenium.remote.html5.RemoteLocationContext.location(RemoteLocationContext.java:38)
    at org.openqa.selenium.chrome.ChromeDriver.location(ChromeDriver.java:195)
    at org.openqa.selenium.remote.server.handler.html5.GetLocationContext.call(GetLocationContext.java:31)
    at org.openqa.selenium.remote.server.handler.html5.GetLocationContext.call(GetLocationContext.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
01:27:37.029 WARN - Exception thrown
org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
  (Session info: chrome=37.0.2062.124)
  (Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_51'
Session ID: 25d1fbe63300966edb133612003055d1
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/zx/954mnbfn6s145t6d04g5nr5h0000gq/T/.org.chromium.Chromium.dGVeyG}, rotatable=false, locationContextEnabled=true, version=37.0.2062.124, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:614)
    at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:32)
    at org.openqa.selenium.remote.html5.RemoteLocalStorage.size(RemoteLocalStorage.java:72)
    at org.openqa.selenium.remote.server.handler.html5.GetLocalStorageSize.call(GetLocalStorageSize.java:30)
    at org.openqa.selenium.remote.server.handler.html5.GetLocalStorageSize.call(GetLocalStorageSize.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
01:27:47.173 WARN - Exception: unknown error: Location must be set before it can be retrieved
  (Session info: chrome=37.0.2062.124)
  (Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3 milliseconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_51'
Session ID: 25d1fbe63300966edb133612003055d1
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/zx/954mnbfn6s145t6d04g5nr5h0000gq/T/.org.chromium.Chromium.dGVeyG}, rotatable=false, locationContextEnabled=true, version=37.0.2062.124, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
01:27:57.321 WARN - Exception: unknown error: Runtime.evaluate threw exception: SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
  (Session info: chrome=37.0.2062.124)
  (Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'N/A', ip: 'N/A', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_51'
Session ID: 25d1fbe63300966edb133612003055d1
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/zx/954mnbfn6s145t6d04g5nr5h0000gq/T/.org.chromium.Chromium.dGVeyG}, rotatable=false, locationContextEnabled=true, version=37.0.2062.124, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
01:28:27.773 INFO - Executing: [get: data:text/html;charset=utf-8,%3C!DOCTYPE%20html%3E%3Ctitle%3Ea%3C%2Ftitle%3E])
01:28:27.794 INFO - Done: [get: data:text/html;charset=utf-8,%3C!DOCTYPE%20html%3E%3Ctitle%3Ea%3C%2Ftitle%3E]
01:28:27.799 INFO - Executing: [get title])
01:28:27.803 INFO - Done: [get title]
...

My intern configuration looks like:

define({
  proxyPort: 9000,
  proxyUrl: 'http://localhost:9000/',

  capabilities: {
    'selenium-version': '2.43.1'
  },

  environments: [
    { browserName: 'chrome'}
  ],

  maxConcurrency: 3,

  tunnel: 'NullTunnel',
  loader: {},
  suites: [],

  functionalSuites: 'tests/all_functional',

  reporters: ['console'],
  excludeInstrumentation: /^tests\//
});

I tried to use Selenium 2.42.2 with chromedriver 2.10 and chromedriver 2.9 but the results are similar.

Update 1

The same problem persist with OSX 10.10, Java 1.7.0_51 (Java 7 update 71), chromedriver 2.11 and Chrome 38.0.2125.104.

Update 2

I started looking at why there is such a big delay between HttpContext and ServletHandler startup. Debug shows that New random session seed takes that long time (5 sec). It seems that all errors that take longer time have time that is multiple of 5 (5 sec, 10 sec and 25 sec).

On other Unix systems this problem was solved by replacing /dev/random by /dev/urandom but on OSX there should be no difference between them. I tried feeding /dev/random with data while selenium was running but it didn't help.

Running with sudo gives the same result.

Specifying -Djava.security.egd=file:///dev/urandom gives the same result.

Update 3 On a new machine problem disappeared. And as I have no more the old machine - the answer will remain a mystery.

The only thing that I think could be different between these machines is JDK.


回答1:


I ran into this issue on macOS Sierra when using selenium-standalone-server 2.42.2 and chromedriver 2.25. I tried several version combinations of the two while using java version 1.8.0_91 to no avail.

The issue was resolved by reverting to a previous version of java, java version 1.8.0_45. Not the best solution, so I'm using http://www.jenv.be/ to go back and forth when I need to. This does not identify the issue's root cause but I hope this workaround helps someone, took me a while to find it.



来源:https://stackoverflow.com/questions/26213191/local-functional-tests-start-after-more-then-1-minute

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!