如何使用 Selenium RC / Java 以编程方式删除多域 cookie

发布于 2024-09-25 04:26:53 字数 442 浏览 9 评论 0原文

Selenium 具有 deleteallvisiblecookies 构造,当测试在同一域中运行时,该构造会删除所有 cookie。

对于调用访问控制的产品,例如,通常 URL 被访问管理器产品捕获,用户被重定向到不同的域进行登录,然后在登录成功时重定向回原始 URL,这似乎并不工作

根据 Selenese 文档:

要删除cookie,您需要删除 它使用完全相同的路径并且 用于创建的域 曲奇饼。如果路径错误或者 域名错误,cookie只是 不会被删除。

我似乎无法在这种多域环境中删除所有 cookie。

我们使用 Java 和 Selenium RC 来运行这些测试 - 通常使用 Firefox,但也使用一些 IE。

有谁有一些 Java 代码示例或一些我可以用来解决这个问题的建议吗?

Selenium has the deleteallvisiblecookies construct which deletes all cookies when the tests run in the same domain.

For products that invoke access control e.g. typically the URL is trapped by the access manager product and the user is redirected to a different domain to log-in and then redirected back to the original URL is the login is successful, this doesn't seem to work

As per the Selenese documentation:

To delete a cookie, you need to delete
it using the exact same path and
domain that were used to create the
cookie. If the path is wrong, or the
domain is wrong, the cookie simply
won't be deleted.

I can't seem to get all the cookies deleted in this kind of multi-domain environment.

We use Java and Selenium RC to run these tests - typically using Firefox but some IE.

Has anyone got some Java code samples or some suggestions that I could use to resolve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

§普罗旺斯的薰衣草 2024-10-02 04:26:53

我认为你不能。 Selenium RC 的 Java 部分只是使用它生成的 JavaScript 来控制浏览器。一切都在浏览器中执行,因此通常的跨域规则适用。

我唯一能想到的就是制作一些看起来像是来自访问管理器域的代理页面,并让该页面删除“其”cookie。 Selenium RC 已经包含一个代理(这就是它的工作原理),也许有一种方法可以向代理域添加一些假页面。

I don't think you can. The Java part of Selenium RC is just controlling the browser using JavaScript that it generates. Everything executes in the browser, so the usual cross-domain rules apply.

The only thing I can think of is making some proxy page that looks like it is coming from the access manager domain and have that one delete "its" cookies. Selenium RC already includes a proxy (that is how it works), maybe there is a way to add some fake pages to the proxied domains.

作死小能手 2024-10-02 04:26:53

我相信你可以查询 Selenium RC 来找出它正在运行的浏览器 - 如果你能做到这一点,你可以让你的测试转到浏览器存储 cookie 的位置(假设你可以在运行时确定它) Firefox 配置文件的情况 - 也许看看创建日期?)并通过文件系统删除 cookie。那么你就不会涉及 Selenium,也不会出现域指定问题。

I believe you can query Selenium RC to find out what browser it's running in - if you can do that, you could have your tests go out to the location where the browser is storing the cookies (assuming you can determine it at run-time in the case of the Firefox profiles - maybe look at creation date?) and deleting cookies through the file system. Then you'd have no Selenium involvement and no domain specifying problems.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文