instaclick / php-webdriver

W3C and Selenium 2 webdriver "thin client" for php 5.3+ and namespaces.
Other
436 stars 62 forks source link

moveto returns "unknown command" on v4.3.0 of chrome webdriver #118

Closed vasilake-v closed 9 months ago

vasilake-v commented 2 years ago

Hey All !

I'm trying to use the new version of "selenium/hub:4.3.0-20220726" and "selenium/node-chrome:4.3.0-20220726" with https://github.com/minkphp/MinkSelenium2Driver but facing a issue related to "clickOnElement()" method

One could say/relay me to MinkSelenium2Driver package discussion, but i still think this is something related to php-webdriver and its method support for webdrivers.

During "clickOnElement()" method, on webdriver the moveto and click() is called. php-webdriver throws exception during moveto() action, after POST http://127.0.0.1:4444/wd/hub/session/:sessionId/moveto, which is accepted by selenium-hub... it returns a response with error details "error": "command unknown"

I've created a Pull-request but i'm not 100% sure whether the approach is the right one (seems to be though) https://github.com/instaclick/php-webdriver/pull/117

I'd appreciate some guidance here

Thank you!

Saeven commented 1 year ago

@slava-v I'm running into the same problem using:

Had you solved this? I get logs that look like:

#0 /vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(174): WebDriver\Exception::factory(-8, 'Unable to execu...')
#1 /vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(234): WebDriver\AbstractWebDriver->curl('POST', '/moveto', Array)
#2 /vendor/instaclick/php-webdriver/lib/WebDriver/Container.php(241): WebDriver\AbstractWebDriver->__call('moveto', Array)
#3 /vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php(798): WebDriver\Container->__call('moveto', Array)
justafish commented 1 year ago

I've opened a PR to fix this #120

vasilake-v commented 1 year ago

@Saeven

The issue was fixed for me with instaclick/php-webdriver: 1.4.15

So my setup is slightly different

container image: selenium/node-chrome: 4.3.0-20220726

composer.lock

behat/behat: v3.10.0
behat/mink: v1.10.0
behat/mink-extension: 2.3.1
behat/mink-selenium2-driver: v1.6.0
instaclick/php-webdriver: 1.4.15

behat.yml.dist

extensions:
        Behat\MinkExtension:
            sessions:
                default:
                    symfony2: ~
                javascript:
                    selenium2:
                        wd_host: "http://selenium-hub:4444/wd/hub" # Docker configuration
                        capabilities:
                            browserName: 'chrome'
                            marionette: false
                            browser: 'chrome'
                            platform: "LINUX"
                            version: ''
                            extra_capabilities:
                                idle-timeout: 600
                                command-timeout: 600
                                max-duration: 14400
                                chromeOptions:
                                    args:
                                        - "start-maximized"

docker-compose.yml

    selenium-hub:
        image: selenium/hub:4.3.0-20220726
        ports:
            - "4444:4444"

    selenium-node-chrome:
        image: selenium/node-chrome:4.3.0-20220726
        volumes:
            - "${PROJECT_ROOT:-.}/var/chrome:/tmp/"
        ports:
@@ -91,9 +91,12 @@ services:
            SCREEN_DEPTH: 24
            NODE_MAX_SESSION: 1
            NODE_MAX_INSTANCES: 1
            SE_EVENT_BUS_HOST: selenium-hub
            SE_EVENT_BUS_PUBLISH_PORT: 4442
            SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
        shm_size: 2G
        depends_on:
            - selenium-hub
Saeven commented 1 year ago

@slava-v I've tried your configuration just now, but it still unfortunately yields request failures:

Unable to execute request: POST \u002fsession\u002f1528e41bd667b564d12e0bf292a79c9f\u002fmoveto

 [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "345c78266b0b2566aa535d1f0a9b6a05","eventTime": 1670868993454654109,"eventName": "exception","attributes": {"exception.message": "Unable to execute request: POST \u002fsession\u002f1528e41bd667b564d12e0bf292a79c9f\u002fmoveto\nBuild info: version: '4.3.0', revision: 'a4995e2c09*'\nSystem info: host: 'b8fc029cf303', ip: '172.26.0.5', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.49-linuxkit', java.version: '11.0.15'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.UnsupportedCommandException: POST \u002fsession\u002f1528e41bd667b564d12e0bf292a79c9f\u002fmoveto\nBuild info: version: '4.3.0', revision: 'a4995e2c09*'\nSystem info: host: 'b8fc029cf303', ip: '172.26.0.5', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.49-linuxkit', java.version: '11.0.15'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.remote.codec.AbstractHttpCommandCodec.decode(AbstractHttpCommandCodec.java:293)\n\tat org.openqa.selenium.remote.codec.AbstractHttpCommandCodec.decode(AbstractHttpCommandCodec.java:127)\n\tat org.openqa.selenium.grid.web.ProtocolConverter.execute(ProtocolConverter.java:123)\n\tat org.openqa.selenium.grid.node.ProtocolConvertingSession.execute(ProtocolConvertingSession.java:75)\n\tat org.openqa.selenium.grid.node.local.SessionSlot.execute(SessionSlot.java:125)\n\tat org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:447)\n\tat org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35)\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.node.Node.execute(Node.java:240)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.base\u002fjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base\u002fjava.util.concurrent.FutureTask.run(FutureTask.java:264)\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.UnsupportedCommandException","http.flavor": 1,"http.handler_class": "org.openqa.selenium.remote.http.Route$PredicatedRoute","http.host": "localhost:4444","http.method": "POST","http.request_content_length": "50","http.scheme": "HTTP","http.target": "\u002fsession\u002f1528e41bd667b564d12e0bf292a79c9f\u002fmoveto","http.user_agent": "selenium\u002f4.3.0 (java unix)"}}
vasilake-v commented 1 year ago

@Saeven , that really looks strange.

You say that you tried with same versions? :thinking: Could it be that the your vendor folder still has the old package ? (remove all packages and reinstall / clean composer cache)

If you tried with newer version, then the only things that come to my mind is that the bug was reintroduced :disappointed:

justafish commented 1 year ago

Could this issue be re-opened please @robocoder ?

robocoder commented 1 year ago

Re-opening for further investigation.

justafish commented 1 year ago

Just to explain why I think #120 is the solution @robocoder - moveTo was removed from Selenium in April 2021 as it's not compliant with the spec. Removing the command from this library will cause Mink to raise an exception that the command doesn't exist (rather than erroring out completely as it currently does) See https://github.com/minkphp/MinkSelenium2Driver/blob/master/src/Selenium2Driver.php#L800 which also references moveto as not being in the W3C WebDriver spec.

I'd appreciate if you could explain why you don't think this should be removed? Thanks! :smile_cat:

robocoder commented 1 year ago

I know the command is unsupported in the W3C spec but I can't ignore the BC aspect of this library.

justafish commented 1 year ago

@robocoder could we make a 2.x.x release, otherwise what would your preferred solution be along the lines of?

Saeven commented 1 year ago

I would like to voice a small vote for what @justafish suggests: a semver intention to flag the BC.

Perhaps the PR is indeed not the right solution, there I defer to your team!

However, a semver promotion that removes the deprecated command would save our CI chain logs and make logs useful once again. Right now, we're left to wade through hundreds of thousands of lines that are being padded to 40x intended size because of barrage of org.openqa.selenium.UnsupportedCommandException

Thank you for your efforts! I know OSS can be a thankless job!

Saeven commented 1 year ago

@robocoder in case it helps, I've created a rig to easily reproduce the problem at https://github.com/Saeven/behat-moveto-test

justafish commented 1 year ago

@robocoder can you provide some guidance here please if you're unwilling to remove the command to cause it to raise an exception? I understand the BC break concerns, but this is already broken for anyone who isn't using a > 1 year old release now

aik099 commented 6 months ago

The https://github.com/minkphp/MinkSelenium2Driver/commit/7aa0e146ebd780a8a9a8214edd2c7ee5cc34b446 commit made it possible for MinkSelenium2Driver to handle an attempt to call non-existing moveto command. The fix is available in the MinkSelenium2Driver v1.7.

aik099 commented 6 months ago

How you managed to get MinkSelenium2Driver working with Selenium 4?

For me instaclick/php-webdriver 1.x doesn't even connect to Selenium 4, because it can talk only JsonWireProtocol, but Selenium 4 is W3C only.