gpt4 book ai didi

cookies - 程序在 Selenium Grid 上运行时如何删除 Firefox Cookies 和缓存?

转载 作者:行者123 更新时间:2023-12-02 00:41:05 25 4
gpt4 key购买 nike

我正在运行 Selenium Grid,但由于无法删除 Firefox cookie,我的大部分脚本都失败了。每个测试用例都需要删除浏览器 cookie。如果有人知道如何执行此操作,请告诉我。

最佳答案

您可以使用 Selenium 的 deleteCookie 函数来删除 cookie,您可以将其放入测试设置中。 deleteCookie 的文档如下

deleteCookie(name, optionsString) Arguments:

    * name - the name of the cookie to be deleted
* optionsString - options for the cookie. Currently supported

options include 'path', 'domain' and 'recurse.' The optionsString's format is "path=/path/, domain=.foo.com, recurse=true". The order of options are irrelevant. Note that specifying a domain that isn't a subset of the current domain will usually fail.

Delete a named cookie with specified path and domain. Be careful;

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. Also note that specifying a domain that isn't a subset of the current domain will usually fail. Since there's no way to discover at runtime the original path and domain of a given cookie, we've added an option called 'recurse' to try all sub-domains of the current domain with all paths that are a subset of the current path. Beware; this option can be slow. In big-O notation, it operates in O(n*m) time, where n is the number of dots in the domain name and m is the number of slashes in the path.

关于cookies - 程序在 Selenium Grid 上运行时如何删除 Firefox Cookies 和缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2544367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com