看起来您的网站存储了不同域的 cookie,或 httponly cookie。
Webdriver 只能删除您当前所在域的 cookie。因此,如果您的 API 为您提供了一些 authtoken - 它不会被删除,因为它存储在不同的域中。HTTPonly cookie 也是如此。
HttpOnly cookie
An HttpOnly cookie cannot be accessed by client-side APIs, such as JavaScript. This restriction eliminates the threat of cookie theft via cross-site scripting (XSS). However, the cookie remains vulnerable to cross-site tracing (XST) and cross-site request forgery (XSRF) attacks. A cookie is given this characteristic by adding the HttpOnly flag to the cookie.
我建议您导航到 API url,并browser.manage().deleteAllCookies();
在那里调用方法或在您的站点上调用手动注销