selenium-to-restassured
December 6, 2018 ยท View on GitHub
Easily share Selenium WebDriver cookies with Rest Assured back and forth with this Java api.
Installation
Download the latest jar and add to your project. You can then add it to your maven project by adding the following dependency:
<dependency>
<groupId>uk.co.mwtestconsultancy</groupId>
<artifactId>selenium-to-restassured</artifactId>
<version>0.3</version>
</dependency>
Usage
You have two options you can either convert from RestAssured to Selenium:
io.restassured.http.Cookie cookieToConvert = response.getDetailedCookie("COOKIE NAME")
CookieAdapter cookieAdapter = new CookieAdapter();
org.openqa.selenium.Cookie convertedCookie = cookieAdapter.convertToSelenium(cookieToConvert);
Or you can convert from Selenium to RestAssured
org.openqa.selenium.Cookie cookieToConvert = driver.manage().getCookieNamed("COOKIE NAME");
CookieAdapter cookieAdapter = new CookieAdapter();
io.restassured.http.Cookie adaptedCookie = cookieAdapter.convertToRestAssured(seleniumCookie);
Additionally CookieAdapter will take an enum to convert Selenium expiry dates into either:
Expiry Dates
CookieAdapter cookieAdapter = new CookieAdapter(ExpiryType.EXPIRY);
Max Age
CookieAdapter cookieAdapter = new CookieAdapter(ExpiryType.MAXAGE);