我想用selenium创建一个cookie。我已经看到了一个像selenium.createcookie(arg1,arg0)
这样支持它的方法,但我对传递的参数感到有点困惑。有人可以举个例子吗?
答案 0 :(得分:6)
createCookie(nameValuePair,optionsString) 创建一个新的cookie,其路径和域与当前测试页面的路径和域相同,除非您明确指定了此cookie的路径。
参数:
nameValuePair - 的名称和值 cookie的格式为“name = value”
optionsString - 的选项 曲奇饼。目前支持的选项 包括'path'和'max_age'。该 optionsString的格式是 “path = / path /,max_age = 60”。命令 期权是不相关的,单位 'max_age'的值是第二。
答案 1 :(得分:1)
createCookie ( nameValuePair,optionsString )
创建一个新的cookie,其路径和域与当前测试页面的路径和域相同,除非您明确指定了此cookie的路径。
Arguments:
nameValuePair - name and value of the cookie in a format "name=value"
optionsString - options for the cookie. Currently supported options include 'path' and 'max_age'. the optionsString's format is "path=/path/, max_age=60". The order of options are irrelevant, the unit of the value of 'max_age' is second.
答案 2 :(得分:1)
使用firefox访问您选择的网站(确实创建Cookie),然后转到编辑>偏好设置>隐私>删除个别Cookie。单击其中一个cookie。这将让您了解如何使用createCookie调用。我将选项Domain的术语切换为Host by term,这很好。