def clear_cookie_by_name(context, cookie_cleared_name): cookies = context.cookies() filtered_cookies = [ cookie for cookie in cookies if cookie["name"] != cookie_cleared_name ] context.clear_cookies() context.add_cookies(filtered_cookies)