我有一个注册有6个节点(Vista和WIN10)的集线器。
一切正常,直到我更改了以下项的依赖项注入为止: 脚本->调用另一个实例化webdriver的项目。我使用spring框架进行依赖项注入,因为我需要使用webdriver来使用Proxy,如下所示: ...
<constructor-arg name="headless" value="${hHeadless}"/>
<constructor-arg name="proxyip" value="${proxyip:}"/>
<constructor-arg name="proxyport" value="${proxyport:}"/>
调用WebDriver的构造器。
但是现在当我尝试使用以下cmd运行项目时:
mvn clean test -Dit.test=*Test#testName -DfailIfNoTests=false -DbrowserType=Chrome -DbrowserVersion=ANY -DosName=WIN10 -DthreadCount=32 ...
我遇到以下崩溃:
SessionId not found. Running the test locally?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.webDriver' defined in class path resource [application-context-web.xml]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'getWebDriver' threw exception; nested exception is org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: unknown
remote stacktrace: Backtrace:
Ordinal0 [0x00D7D383+3134339]
Ordinal0 [0x00C6A171+2007409]
Ordinal0 [0x00B0AEE8+569064]
Ordinal0 [0x00AB0358+197464]
Ordinal0 [0x00AAFDC8+196040]
Ordinal0 [0x00AB0CB7+199863]
Ordinal0 [0x00AB0C1D+199709]
Ordinal0 [0x00AAEB0B+191243]
Ordinal0 [0x00A92E77+77431]
Ordinal0 [0x00A93E3E+81470]
Ordinal0 [0x00A93DC9+81353]
Ordinal0 [0x00C80CD9+2100441]
GetHandleVerifier [0x00EEB75A+1396954]
GetHandleVerifier [0x00EEB3D9+1396057]
GetHandleVerifier [0x00EF7126+1444518]
GetHandleVerifier [0x00EEBCE8+1398376]
Ordinal0 [0x00C77F51+2064209]
Ordinal0 [0x00C822EB+2106091]
Ordinal0 [0x00C82411+2106385]
Ordinal0 [0x00C949C4+2181572]
BaseThreadInitThunk [0x77306359+25]
RtlGetAppContainerNamedObjectPath [0x77647C24+228]
RtlGetAppContainerNamedObjectPath [0x77647BF4+180]
Command duration or timeout: 598 milliseconds
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:345)
at <packagename>.ThreadScope.get(ThreadScope.java:28)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
at <packagename>.getTargetObject(PUtils.java:14)
at <packagename>.setUp(BaseSelTestCase.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:589)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'getWebDriver' threw exception; nested exception is org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: unknown
remote stacktrace: Backtrace:
Ordinal0 [0x00D7D383+3134339]
Ordinal0 [0x00C6A171+2007409]
Ordinal0 [0x00B0AEE8+569064]
Ordinal0 [0x00AB0358+197464]
Ordinal0 [0x00AAFDC8+196040]
Ordinal0 [0x00AB0CB7+199863]
Ordinal0 [0x00AB0C1D+199709]
Ordinal0 [0x00AAEB0B+191243]
Ordinal0 [0x00A92E77+77431]
Ordinal0 [0x00A93E3E+81470]
Ordinal0 [0x00A93DC9+81353]
Ordinal0 [0x00C80CD9+2100441]
GetHandleVerifier [0x00EEB75A+1396954]
GetHandleVerifier [0x00EEB3D9+1396057]
GetHandleVerifier [0x00EF7126+1444518]
GetHandleVerifier [0x00EEBCE8+1398376]
Ordinal0 [0x00C77F51+2064209]
Ordinal0 [0x00C822EB+2106091]
Ordinal0 [0x00C82411+2106385]
Ordinal0 [0x00C949C4+2181572]
BaseThreadInitThunk [0x77306359+25]
RtlGetAppContainerNamedObjectPath [0x77647C24+228]
RtlGetAppContainerNamedObjectPath [0x77647BF4+180]
Command duration or timeout: 598 milliseconds
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 26 more
Caused by: org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'XGHSGHSG', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: unknown
remote stacktrace: Backtrace:
Ordinal0 [0x00D7D383+3134339]
Ordinal0 [0x00C6A171+2007409]
Ordinal0 [0x00B0AEE8+569064]
Ordinal0 [0x00AB0358+197464]
Ordinal0 [0x00AAFDC8+196040]
Ordinal0 [0x00AB0CB7+199863]
Ordinal0 [0x00AB0C1D+199709]
Ordinal0 [0x00AAEB0B+191243]
Ordinal0 [0x00A92E77+77431]
Ordinal0 [0x00A93E3E+81470]
Ordinal0 [0x00A93DC9+81353]
Ordinal0 [0x00C80CD9+2100441]
GetHandleVerifier [0x00EEB75A+1396954]
GetHandleVerifier [0x00EEB3D9+1396057]
GetHandleVerifier [0x00EF7126+1444518]
GetHandleVerifier [0x00EEBCE8+1398376]
Ordinal0 [0x00C77F51+2064209]
Ordinal0 [0x00C822EB+2106091]
Ordinal0 [0x00C82411+2106385]
Ordinal0 [0x00C949C4+2181572]
BaseThreadInitThunk [0x77306359+25]
RtlGetAppContainerNamedObjectPath [0x77647C24+228]
RtlGetAppContainerNamedObjectPath [0x77647BF4+180]
当我在Web驱动程序调用代码中打印值时,我看到正在使用以下功能:
-----------------Platform.fromString(osName)-----------WIN10:WIN10
----- Options ----- {acceptSslCerts=true, browserName=chrome, goog:chromeOptions={args=[start-maximized, --test-type, --disable-extensions, --disable-gpu, --no-sandbox, enable-automation, --disable-infobars, --disable-dev-shm-usage], extensions=[], prefs={profile.default_content_settings.popups=0, download.default_directory=<some path>}}, loggingPrefs=org.openqa.selenium.logging.LoggingPreferences@88ff2b28, pageLoadStrategy=normal, platformName=WIN10, unexpectedAlertBehaviour=ignore, unhandledPromptBehavior=ignore, version=ANY}
Exception in thread "Thread-4" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.webDriver' defined in class path resource [application-context-web.xml]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'getWebDriver' threw exception; nested exception is org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
有些奇怪:
mvn clean integration-test -Dit.test=*test -DfailIfNoTests=false -DbrowserType=Chrome -DbrowserVersion=ANY ***-DosName=Windows*** -DthreadCount=32 -DparallelMode=methods -DisRemote=true -DbrowserHeadless=false -DdoRetryIfFailed=false -DpropertyFile=properties_file
它确实调用了该节点上的测试和浏览器。但是,该节点已注册为平台:WIN10
{
"capabilities":
[{
"seleniumProtocol": "WebDriver",
"browserName": "firefox",
"maxInstances": 4,
"version": "ANY",
"platform": "WIN10",
"firefox_binary":"C:\\Program Files\\Mozilla Firefox\\firefox.exe",
"extension.sikuliCapability": true
},
{
"seleniumProtocol": "WebDriver",
"browserName": "chrome",
"maxInstances": 7,
"version": "ANY",
"platform": "WIN10"
},
{
"seleniumProtocol": "WebDriver",
"browserName": "internet explorer",
"maxInstances": 1,
"version": "11",
"platform": "WIN10"
},
{
"seleniumProtocol": "WebDriver",
"browserName": "MicrosoftEdge",
"maxInstances": 1,
"version": "ANY",
"platform": "WIN10"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 7,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://hubname:4444/hub/wd/",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
}
节点上的两个调用如下:
不成功:
ChromeDriver was started successfully.
00:15:04.339 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"acceptSslCerts": true,
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
"start-maximized",
"--test-type",
"--disable-extensions",
"--disable-gpu",
"--no-sandbox",
"enable-automation",
"--disable-infobars",
"--disable-dev-shm-usage"
],
"extensions": [
],
"prefs": {
"profile.default_content_settings.popups": 0,
"download.default_directory": "path"
}
},
"loggingPrefs": {
"browser": "ALL"
},
"pageLoadStrategy": "normal",
"platformName": "win10",
"unexpectedAlertBehaviour": "ignore",
"unhandledPromptBehavior": "ignore",
"version": "ANY"
}
00:15:04.340 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}) on port 38686
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
成功:
ChromeDriver was started successfully.
00:45:30.351 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"acceptSslCerts": true,
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
"start-maximized",
"--test-type",
"--disable-extensions",
"--disable-gpu",
"--no-sandbox",
"enable-automation",
"--disable-infobars",
"--disable-dev-shm-usage"
],
"extensions": [
],
"prefs": {
"profile.default_content_settings.popups": 0,
"download.default_directory": "path"
}
},
"loggingPrefs": {
"browser": "ALL"
},
"pageLoadStrategy": "normal",
"platformName": "windows",
"proxy": {
"httpProxy": "proxyip",
"proxyType": "manual",
"sslProxy": "proxyip"
},
"unexpectedAlertBehaviour": "ignore",
"unhandledPromptBehavior": "ignore",
"version": "ANY"
}
00:45:30.352 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}) on port 2728
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
00:45:33.739 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
00:45:33.740 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session a35ad5b66b8ecdf0da726a29c0601baa (org.openqa.selenium.chrome.ChromeDriverService)
00:45:33.851 INFO [ActiveSessions$1.onStop] - Removing session a35ad5b66b8ecdf0da726a29c0601baa (org.openqa.selenium.chrome.ChromeDriverService)
这是在我使用ChromeOption时发生的,但从未与DesiredCapabilities一起发生,如下所示:
此处不崩溃
capabilities.setCapability(CapabilityType.PLATFORM_NAME, Platform.fromString(osName));
WebDriver chromeDriver = new ChromeDriver(capabilities);
看到崩溃
chromeOptions.setCapability(CapabilityType.PLATFORM_NAME, Platform.fromString(osName));
WebDriver chromeDriver = new ChromeDriver(chromeOptions);