php - 使用 Behat 和 Selenium2 驱动程序运行测试失败,因为 DevToolsActivePort 文件不存在
问题描述
我正在尝试为使用 Behat 和 Selenium 的 Chrome 浏览器运行一些测试
我安装了最新的 chrome / chromium 驱动程序:
root@dee4c77efe99:/var/www/bsm/scripts/bin/selenium# ./chromedriver --version
ChromeDriver 95.0.4638.17 (a9d0719444d4b035e284ed1fce73bf6ccd789df2-refs/branch-heads/4638@{#178})
root@dee4c77efe99:/var/www/bsm/scripts/bin/selenium# /usr/bin/google-chrome --version
Google Chrome 95.0.4638.54
另外,我的 behat.yml 配置如下:
extensions:
Behat\MinkExtension:
goutte:
guzzle_parameters:
curl.options:
CURLOPT_SSL_VERIFYPEER: false
CURLOPT_CERTINFO: false
CURLOPT_TIMEOUT: 120
ssl.certificate_authority: false
browser_name: chrome
javascript_session: selenium2
# configure the base url for your site
base_url: https://example.io
selenium2:
wd_host: http://172.19.0.7:4444
capabilities:
browserName: chrome
marionette: true
extra_capabilities:
loggingPrefs:
performance: ALL
browser: ALL
chromeOptions:
w3c: false
args:
- "--headless"
- "--no-sandbox"
- "--disable-dev-shm-usage"
- "--disable-gpu"
- "--dns-prefetch-disable"
- "--disable-setuid-sandbox"
- "--window-size=1920,1080"
- "--remote-debugging-port=9222"
出于某种原因,它尝试创建的第一个会话由于 DevToolsActivePort 错误而失败,尽管它创建的第二个会话正常现在我的问题是,为什么它在第一个会话中崩溃,然后在第二个会话中成功?
12:40:54.509 INFO [LocalDistributor.newSession] - Session request received by the distributor:
[Capabilities {}, Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --no-sandbox, --disable-dev-shm-usage, --disable-gpu, --dns-prefetch-disable, --disable-setuid-sandbox, --window-size=1920,1080, --remote-debugging-port=9222], w3c: false}, goog:loggingPrefs: {browser: ALL, performance: ALL}}, Capabilities {browser: firefox, browserName: chrome, chromeOptions: {args: [--headless, --no-sandbox, --disable-dev-shm-usage, --disable-gpu, --dns-prefetch-disable, --disable-setuid-sandbox, --window-size=1920,1080, --remote-debugging-port=9222], w3c: false}, ignoreZoomSetting: false, loggingPrefs: org.openqa.selenium.logging..., marionette: true, name: Behat feature suite, tags: [dee4c77efe99, PHP 7.3.28-1+ubuntu18.04.1+...]}, Capabilities {browserName: firefox}]
Starting ChromeDriver 95.0.4638.17 (a9d0719444d4b035e284ed1fce73bf6ccd789df2-refs/branch-heads/4638@{#178}) on port 37355
All remote connections are allowed. Use an allowlist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
12:41:54.807 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "a85f6ae0fc0fb48ce1ff179e41e3b562","eventTime": 1635252114857538700,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:37355","exception.message": "Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: DevToolsActivePort file doesn't exist\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: 'dee4c77efe99', ip: '172.19.0.7', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: DevToolsActivePort file doesn't exist\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: 'dee4c77efe99', ip: '172.19.0.7', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:131)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:65)\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:143)\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:315)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:513)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:440)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:648)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:612)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.node.config.DriverServiceSessionFactory","session.capabilities": "{}\n"}}
Starting ChromeDriver 95.0.4638.17 (a9d0719444d4b035e284ed1fce73bf6ccd789df2-refs/branch-heads/4638@{#178}) on port 40044
All remote connections are allowed. Use an allowlist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
12:41:54.967 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
12:41:54.985 INFO [LocalDistributor.newSession] - Session created by the distributor. Id: b304c9299e16a49fa5457ba1d690b10e, Caps: Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 95.0.4638.17 (a9d0719444d4b..., userDataDir: /tmp/.com.google.Chrome.ezZXGW}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:9222}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, proxy: Proxy(), rotatable: false, se:cdp: ws://172.19.0.7:4444/sessio..., se:cdpVersion: 95.0.4638.54, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 95.0.4638.54, webStorageEnabled: true, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
12:42:16.801 INFO [LocalSessionMap.lambda$new$0] - Deleted session from local session map, Id: b304c9299e16a49fa5457ba1d690b10e
解决方案
推荐阅读
- foreach - Kotlin:遍历列表并在索引处添加项目
- firebase - 可以在单个控制台内创建多个 Firestore 数据库实例吗?
- javascript - 从动态生成的数组对象中查找键
- content-security-policy - 内容安全策略 - data:image/svg+xml 在 img-src 中被忽略
- azure - 不同地理数据中心中的 Azure 数据工厂 v2 和集成运行时
- php - 即使我看到库存,ebay Inventory api 列表也显示为 Out_of_stock
- java - Hibernate 自己在数据库中创建列
- javascript - 不断检查对象值,如果为假则结束进程
- https - 在 rails session_store 配置中启用安全选项时未设置 Cookie?
- android - 解析 Json 数据 OSM