Here is some code that works for me on MacOS Sonoma (14.2.1):
tell application "System Events" to tell application process "NotificationCenter"
try
log (actions of UI elements of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter" of application "System Events")
perform (actions of UI elements of UI element 1 of scroll area 1 of group 1 of window "Notification Center" of application process "NotificationCenter" of application "System Events" whose name starts with "Name:Close")
end try
end tell
Instead of whose name starts with "Name:Close"
you may use whose name description is "Name:Fermer"
in French, or your own language.
I added a log line so that you can check which action you wish to perform.
Anyway, this has been a PITA for so long, hope this helps.
Check this for the Monterey version: https://apple.stackexchange.com/a/467607/303345