Open katanakatana123 opened 10 months ago
@katanakatana123, thank you for creating this issue. We will troubleshoot it as soon as we can.
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template
label.
If the issue is a question, add the I-question
label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted
label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-*
label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer
label.
Thank you!
You can't add a cookie that doesn't exist. You need at least a name and value. https://www.selenium.dev/documentation/webdriver/interactions/cookies/?tab=csharp#add-cookie
@nvborisenko shouldn't this fail for not sending a cookie instance to the method?
The issue is reproduced, thanks for the report.
It is related to Native AOT.
driver.Url = "https://google.com";
driver.Manage().Cookies.AddCookie(new Cookie("a", "b"));
Unhandled Exception: OpenQA.Selenium.WebDriverArgumentException: invalid argument: missing 'name'
(Session info: chrome=120.0.6099.130)
at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response, String) + 0x511
at OpenQA.Selenium.WebDriver.Execute(String, Dictionary`2) + 0x65
at OpenQA.Selenium.CookieJar.AddCookie(Cookie) + 0x6a
Ah, we have logs! :)
00:54:05.780 DEBUG HttpCommandExecutor: Executing command: [0e18a5deeb9cd0f0b4b44625d29d74f2]: addCookie {"cookie":{}}
00:54:05.781 TRACE HttpCommandExecutor: >> Method: POST, RequestUri: 'http://localhost:57283/session/0e18a5deeb9cd0f0b4b44625d29d74f2/cookie', Version: 1.1, Content: System.Net.Http.ByteArrayContent, Headers:
{
Accept: application/json; charset=utf-8
Content-Type: application/json; charset=utf-8
}
00:54:05.784 TRACE HttpCommandExecutor: << StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Cache-Control: no-cache
Content-Length: 903
Content-Type: application/json; charset=utf-8
}
00:54:05.784 DEBUG HttpCommandExecutor: Response: ( InvalidArgument: System.Collections.Generic.Dictionary`2[System.String,System.Object])
Here we can see that AddCookie command serialized improperly.
As a workaround you can mark your method, which invokes AddCookie
method, with the following attribute:
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Cookie))]
I see even more places in selenium code base where json serialization doesn't work properly with Native AOT.
Hoping #13097 will resolve it.
As a workaround you can mark your method, which invokes
AddCookie
method, with the following attribute:[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Cookie))]
I see even more places in selenium code base where json serialization doesn't work properly with Native AOT.
Hoping #13097 will resolve it.
thank, it working,
Removing it from 4.17 milestone. This is rare case, when we want to be friends with, but cannot do it in discoverable future. I would like to keep it as opened, hoping #13097 resolve it.
Hi @NCLnclNCL, are you able to help us to test the preview version of selenium package which seems to be AOT compatible (excluding CDP)? We are looking for everybody who is interested in it. @katanakatana123 and you?
It should be fixed by https://github.com/SeleniumHQ/selenium/pull/14574
What happened?
when i use driver.Manage().Cookies.AddCookie(); i got the error OpenQA.Selenium.WebDriverArgumentException: invalid argument: missing 'name', i think the problem comes from here https://github.com/SeleniumHQ/selenium/blob/b16d0d8885bbae2a9763bc529156c022c407cf26/dotnet/src/webdriver/WebDriver.cs#L567, when native aot cannot resolve json class
How can we reproduce the issue?
Relevant log output
Operating System
window 10
Selenium version
newest
What are the browser(s) and version(s) where you see this issue?
120
What are the browser driver(s) and version(s) where you see this issue?
120
Are you using Selenium Grid?
No response