当前位置: 首页>>代码示例>>Java>>正文


Java Cookie.getPath方法代码示例

本文整理汇总了Java中org.openqa.selenium.Cookie.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java Cookie.getPath方法的具体用法?Java Cookie.getPath怎么用?Java Cookie.getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.Cookie的用法示例。


在下文中一共展示了Cookie.getPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCookies

import org.openqa.selenium.Cookie; //导入方法依赖的package包/类
/**
 * Get all the cookies for the current domain. This is the equivalent of calling "document.cookie" and parsing the result
 *
 * @return {@link com.axway.ats.uiengine.elements.html.Cookie Cookie}s array
 */
@PublicAtsApi
public com.axway.ats.uiengine.elements.html.Cookie[] getCookies() {

    Set<Cookie> cookies = webDriver.manage().getCookies();
    com.axway.ats.uiengine.elements.html.Cookie[] cookiesArr = new com.axway.ats.uiengine.elements.html.Cookie[cookies.size()];
    int i = 0;
    for (Cookie c : cookies) {
        cookiesArr[i++] = new com.axway.ats.uiengine.elements.html.Cookie(c.getName(),
                                                                          c.getValue(),
                                                                          c.getDomain(),
                                                                          c.getPath(),
                                                                          c.getExpiry(),
                                                                          c.isSecure());
    }
    return cookiesArr;
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:22,代码来源:AbstractHtmlEngine.java

示例2: writeFile

import org.openqa.selenium.Cookie; //导入方法依赖的package包/类
public static void writeFile(String fileName, Set<Cookie> cookies) {
    try {
        File file = new File(fileName);
        FileWriter fileWriter = new FileWriter(file);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        for (Cookie cookie : cookies) {
            String strCookie = cookie.getName() + ";" + cookie.getValue() + ";" + cookie.getDomain() + ";"
                    + cookie.getPath() + ";" + cookie.getExpiry() + ";" + cookie.isSecure() + ";"
                    + cookie.isHttpOnly();
            bufferedWriter.write(strCookie);
            bufferedWriter.newLine();
        }
        bufferedWriter.flush();
        bufferedWriter.close();
        fileWriter.close();
        LogUtils.info("写文件[" + fileName + "]操作成功");
    } catch (Exception e) {
        LogUtils.error("写文件[" + fileName + "]操作失败: " + e.getMessage());
        e.printStackTrace();
    }
}
 
开发者ID:Airpy,项目名称:KeywordDrivenAutoTest,代码行数:22,代码来源:FileUtils.java

示例3: setCookies

import org.openqa.selenium.Cookie; //导入方法依赖的package包/类
public static void setCookies(WebDriver driver,Set<Cookie> cookies){
	if(cookies==null){
		return;
	}
	//Phantomjs存在Cookie设置bug,只能通过js来设置了。
	StringBuilder sb=new StringBuilder();
	for(Cookie cookie:cookies){
		String js="document.cookie=\""+cookie.getName()+"="+cookie.getValue()+";path="+cookie.getPath()+";domain="+cookie.getDomain()+"\";";
		sb.append(js);
	}
	((JavascriptExecutor)driver).executeScript(sb.toString());
}
 
开发者ID:xbynet,项目名称:crawler,代码行数:13,代码来源:WindowUtil.java

示例4: writeCookieToFile

import org.openqa.selenium.Cookie; //导入方法依赖的package包/类
/**
 * 把cookie追加写入cookie文件
 *
 * @param isDeleteFirst 是否先删除cookie文件
 */
public static void writeCookieToFile(Cookie cookie, boolean isDeleteFirst) {
    String strCookie = cookie.getName() + ";" + cookie.getValue() + ";" + cookie.getDomain() + ";"
            + cookie.getPath() + ";" + cookie.getExpiry() + ";" + cookie.isSecure() + ";" + cookie.isHttpOnly();
    if (isDeleteFirst) {
        FileUtils.deleteFile(cookiePath);
        FileUtils.createFile(cookiePath);
    }
    FileUtils.writeFile(cookiePath, strCookie);
}
 
开发者ID:Airpy,项目名称:KeywordDrivenAutoTest,代码行数:15,代码来源:WebCookies.java

示例5: getFromCookie

import org.openqa.selenium.Cookie; //导入方法依赖的package包/类
@Override
public String getFromCookie(Session session, String cookieName, String cookieParameter) {
    Cookie cookie = session.getDriver().manage().getCookieNamed(cookieName);
    if (cookie != null) {
        if (cookieParameter.equals("name")) {
            return cookie.getName();
        }
        if (cookieParameter.equals("expiry")) {
            return cookie.getExpiry().toString();
        }
        if (cookieParameter.equals("value")) {
            return cookie.getValue();
        }
        if (cookieParameter.equals("domain")) {
            return cookie.getDomain();
        }
        if (cookieParameter.equals("path")) {
            return cookie.getPath();
        }
        if (cookieParameter.equals("isHttpOnly")) {
            return String.valueOf(cookie.isHttpOnly());
        }
        if (cookieParameter.equals("isSecure")) {
            return String.valueOf(cookie.isSecure());
        }
    } else {
        return "cookieNotFound";
    }
    return null;
}
 
开发者ID:cerberustesting,项目名称:cerberus-source,代码行数:31,代码来源:WebDriverService.java


注:本文中的org.openqa.selenium.Cookie.getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。