mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.11k stars 1.52k forks source link

Unknown Command is not sending correct error #1962

Open titusfortner opened 2 years ago

titusfortner commented 2 years ago

As part of testing the new shadow root endpoints, I'm running on Firefox and I'm not getting the error I'm expecting.

If the command has not been defined, then I expect to get a 404 response with a "text/json" payload with error value of "unknown command"

Instead I'm getting a 405 response with a "text/plain" payload, body: "HTTP method not allowed"

There's nothing in the Marionette logs:

2021-11-21 23:11:48 INFO Selenium -> POST session/97e180da-b667-9f4c-ac37-e5e980e48002/element
2021-11-21 23:11:48 INFO Selenium    >>> http://127.0.0.1:4444/session/97e180da-b667-9f4c-ac37-e5e980e48002/element | {"using":"xpath","value":".//*[local-name()='div'][@id='shadow_host']"}
2021-11-21 23:11:48 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=UTF-8", "User-Agent"=>"selenium/4.0.2 (ruby macosx)", "Content-Length"=>"71"}
1637557908720   webdriver::server   DEBUG   -> POST /session/97e180da-b667-9f4c-ac37-e5e980e48002/element {"using":"xpath","value":".//*[local-name()='div'][@id='shadow_host']"}
1637557908723   Marionette  DEBUG   0 -> [0,3,"WebDriver:FindElement",{"using":"xpath","value":".//*[local-name()='div'][@id='shadow_host']"}]
1637557908727   Marionette  TRACE   [24] MarionetteCommands actor created for window id 4294967298
1637557908732   Marionette  DEBUG   0 <- [1,3,null,{"value":{"element-6066-11e4-a52e-4f735466cecf":"7627655a-bf31-6249-8cfe-b8971cdde149"}}]
1637557908732   webdriver::server   DEBUG   <- 200 OK {"value":{"element-6066-11e4-a52e-4f735466cecf":"7627655a-bf31-6249-8cfe-b8971cdde149"}}
2021-11-21 23:11:48 INFO Selenium <- {"value":{"element-6066-11e4-a52e-4f735466cecf":"7627655a-bf31-6249-8cfe-b8971cdde149"}}
2021-11-21 23:11:48 INFO Selenium -> GET session/97e180da-b667-9f4c-ac37-e5e980e48002/element/7627655a-bf31-6249-8cfe-b8971cdde149/shadow
2021-11-21 23:11:48 INFO Selenium <- HTTP method not allowed

Selenium::WebDriver::Error::WebDriverError: unexpected response, code=405, content-type="text/plain"
HTTP method not allowed

Fwiw, Safari is returning what I expect to see:

2021-11-21 23:30:52 INFO Selenium <- {"value":{"error":"unknown command","message":"The command 'GET \/session\/215CED6A-189A-4642-978E-47C958DCE530\/element\/node-8C118294-BDD3-4A9C-B94E-DEC393302060\/shadow' was not found.","stacktrace":""}}
whimboo commented 2 years ago

Thanks @titusfortner! We will cover that scenario via https://bugzilla.mozilla.org/show_bug.cgi?id=1742357

GCuser99 commented 1 year ago

This still seems not to be fixed as of v33. Getting 405 response with a "text/plain" payload, body: "HTTP method not allowed" for Geckodriver when I use a mis-specified command path...

whimboo commented 1 year ago

Right, and that's the reason why this issue is still open. Also there is no easy fix for that. You can find more details in the above referenced bug.