如何为selenium test httprequest设置cookie

时间:2012-09-18 15:03:57

标签: selenium selenium-webdriver

我想使用cookie来使用selenium测试来验证登录页面。我正在使用以下形式的代码:

selenium.createCookie("name=Cookie", value);
selenium.open("http://localhost/sample/Login");

但没有结果。无法登录。

1 个答案:

答案 0 :(得分:0)

您必须在selenium.open调用与Cookie相同的域中的URL(在本例中为“http:// localhost / sample”)。然后,您可以使用适当的参数调用selenium.createCookie