minkphp / MinkSelenium2Driver

Selenium2 (webdriver) driver for Mink framework
MIT License
508 stars 162 forks source link

Running tests in Edge browser #343

Open Scobee opened 2 years ago

Scobee commented 2 years ago

Hello, Is it possible to run tests on Edge browser using Mink Selenium2 driver and Selenium 4 grid ?

I've tried using:

default:
    suites:
      default:
        filters:
          tags: ~@wip
        paths: ['%paths.base%/storage/features']
    gherkin:
      cache: ~
    extensions:
      Behat\MinkExtension:
        base_url: http://www.google.com
        javascript_session: selenium2
        browser_name: edge
        selenium2:
          capabilities:
            browserName: MicrosoftEdge
            browser: edge
            extra_capabilities:
              edgeOptions:
                args:
                  - "--no-sandbox"
                  - "--disable-dev-shm-usage"
                  - "--headless"
                  - "--disable-gpu"
                  - "--dns-prefetch-disable"
                  - "--disable-setuid-sandbox"
                  - "--window-size=1920,1080"
                  - "--remote-debugging-port=9222"

But this gives me some errors saying that the DevToolsActivePort file does not exist:

13:38:41.079 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
13:38:41.086 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
13:38:41.942 INFO [NodeOptions.getSessionFactories] - Detected 8 available processors
13:38:41.970 INFO [NodeOptions.discoverDrivers] - Discovered 3 driver(s)
13:38:41.997 INFO [NodeOptions.report] - Adding Edge for {"browserName": "MicrosoftEdge"} 8 times
13:38:41.999 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome"} 8 times
13:38:42.000 INFO [NodeOptions.report] - Adding Firefox for {"browserName": "firefox"} 8 times
13:38:42.039 INFO [Node.<init>] - Binding additional locator mechanisms: id, relative, name
13:38:42.067 INFO [LocalDistributor.add] - Added node fb3c75f0-847d-475d-88b0-dea6893c09c2 at http://172.19.0.7:4444. Health check every 120s
13:38:42.068 INFO [GridModel.setAvailability] - Switching node fb3c75f0-847d-475d-88b0-dea6893c09c2 (uri: http://172.19.0.7:4444) from DOWN to UP
13:38:42.251 INFO [Standalone.execute] - Started Selenium Standalone 4.0.0 (revision 3a21814679): http://172.19.0.7:4444

Starting MSEdgeDriver 95.0.1020.30 (09f7018e2a65a55dea3a0a261efca40ae03471ed) on port 36979
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
[1634828868.563][SEVERE]: bind() failed: Cannot assign requested address (99)
15:07:48.749 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "49c55d39b0c26898585047f89ad32f33","eventTime": 1634828868685689900,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:36979","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: MSEdge failed to start: exited abnormally.\n  (unknown error: DevToolsActivePort file doesn't exist)\n  (The process started from msedge location \u002fusr\u002fbin\u002fmicrosoft-edge is no longer running, so MSEdgeDriver is assuming that MSEdge has crashed.)\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: MSEdge failed to start: exited abnormally.\n  (unknown error: DevToolsActivePort file doesn't exist)\n  (The process started from msedge location \u002fusr\u002fbin\u002fmicrosoft-edge is no longer running, so MSEdgeDriver is assuming that MSEdge has crashed.)\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": "{\"browserName\": \"MicrosoftEdge\"}\n"}}

Is there any way to make this work?

aik099 commented 2 years ago

@Scobee , I've tried googling [SEVERE]: bind() failed: Cannot assign requested address (99) and found https://stackoverflow.com/questions/55844788/how-to-fix-severe-bind-failed-cannot-assign-requested-address-99-while .

Maybe other search results would prove useful.

Scobee commented 2 years ago

@aik099 thanks for your answer! I've read basically everything there was online, but could not find a real solution Although, to be honest, I'm just trying to learn if IT SHOULD work (not necessarily how to make it work .. bc if it should, I'll spend more time with it)

So .. is this config: behat + mink selenium2 driver + selenium 4 grid + edge browser possible ?

aik099 commented 2 years ago

According to https://www.browserstack.com/guide/launch-edge-browser-in-selenium Edge (since the 2020 year) can be used with Selenium.

I recommend trying changing something to see if it works:

  1. try a different web browser (e.g. Firefox, Google Chrome)
  2. try a different selenium grid version (I know, that Selenium 2 works, but Selenium 3 might have issues, never used Selenium 4)
  3. try a different EdgeDriver version (it might be specific to the used Edge version, like with GoogleChrome)