gpt4 book ai didi

java - Selenium java添加cookie

转载 作者:行者123 更新时间:2023-11-30 06:44:01 24 4
gpt4 key购买 nike

Eclipse 给出错误,Date 已弃用。任何人都可以帮忙解决这个问题,我的代码如下使用存储的 cookie 登录脚本。

File file = new File("Cookies.data");                           
FileReader fileReader = new FileReader(file);
BufferedReader Buffreader = new BufferedReader(fileReader);
String strline;
while((strline=Buffreader.readLine())!=null){
String Tokenizertoken = newStringTokenizer(strline,";");
while(token.hasMoreTokens()){
String name = token.nextToken();
String value = token.nextToken();
String domain = token.nextToken();
String path = token.nextToken();
Date expiry = null;
String val;
if(!(val=token.nextToken()).equals("null")){
expiry = new Date(val);
}
Boolean isSecure = new Boolean(token.nextToken()).booleanValue();
Cookie ck = new Cookie(name,value,domain,path,expiry,isSecure);
driver.manage().addCookie(ck); // This will add the stored
cookie to your current session
}
}

最佳答案

您可以使用日历代替日期,因为日期已被弃用

Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime();

关于java - Selenium java添加cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43962381/

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