appium-safari-driver icon indicating copy to clipboard operation
appium-safari-driver copied to clipboard

`POST /session/<session_id>/cookie` fails on 1st try...but succeeds after

Open Fman77 opened this issue 9 months ago • 1 comments

I'm using a python client of selenium, and registered the iOS device through a Selenium Node, and relaying the the commands to an Appium server through the relay configuration of Selenium.

Most of the commands run fine, creating a session, getting to a URL, deleting a cookie.

But when trying to ADD a cookie, the request is failing the 1st time:

[79eff3c3][SafariDriver@781c] Driver proxy active, passing request on via HTTP proxy
[79eff3c3][SafariDriver@781c] Matched '/session/79eff3c3-feff-4732-ad72-89c18f910d9b/cookie' to command name 'setCookie'
[79eff3c3][SafariDriver@781c] Proxying [POST /session/79eff3c3-feff-4732-ad72-89c18f910d9b/cookie] to [POST http://127.0.0.1:5100/session/56E7DCEA-A41A-411A-B5F0-11803DCDB905/cookie] with body: {"cookie":{"name":"someName","value":"someValue","domain":".google.com","path":"/","secure":true}}
[79eff3c3][SafariDriver@781c] Got response with status 405:
[79eff3c3][HTTP] <-- POST /session/79eff3c3-feff-4732-ad72-89c18f910d9b/cookie 400 4 ms - 845

I think that request isn't forwarded to safridriver, I looked at the logs and I don't see it.

Now the exact same subsequent request, without changing anything, works:

[79eff3c3][SafariDriver@781c] Driver proxy active, passing request on via HTTP proxy
[79eff3c3][SafariDriver@781c] Matched '/session/79eff3c3-feff-4732-ad72-89c18f910d9b/cookie' to command name 'setCookie'
[79eff3c3][SafariDriver@781c] Proxying [POST /session/79eff3c3-feff-4732-ad72-89c18f910d9b/cookie] to [POST http://127.0.0.1:5100/session/56E7DCEA-A41A-411A-B5F0-11803DCDB905/cookie] with body: {"cookie":{"name":"someName","value":"someValue","domain":".google.com","path":"/","secure":true}}
[79eff3c3][SafariDriver@781c] Got response with status 200: {"value":null}
[79eff3c3][HTTP] <-- POST /session/79eff3c3-feff-4732-ad72-89c18f910d9b/cookie 200 21 ms - 14

I see that request coming through in safari driver logs, and I then called get_cookies() method (which maps to /cookie but without a request BODY), and I see the cookie that I just set before.

Thanks for looking into it!

Fman77 avatar Jan 15 '25 23:01 Fman77