AppleScript "can't get menu item" error
I think you need to make the menu item "Clear History and Website Data…", not "Clear History and Website Data..." (a single ellipses character: "…" vs. three periods: "..."

I didn't test the whole script, but this change brought the menu item up in Safari for me via AppleScript.