Created
January 22, 2019 11:38
-
-
Save sidd-kulk/cf96a073796119d4ffb21692a4145661 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//.. Imports | |
public class ReportGenerator { | |
private final HttpServletRequest request; | |
private final WebDriver webDriver; | |
public ReportGenerator(HttpServletRequest request){ | |
this.request = request; | |
this.webDriver = new ChromeDriver(...); | |
} | |
public Report createReport(){ | |
// Important part | |
this.webDriver.get("<your app login page>"); | |
// Copy cookies from request sent by user | |
Arrays.stream(this.request.getCookies()).forEach(cookie -> { | |
this.webDriver.manage().addCookie(new Cookie(cookie.getName(), cookie.getValue(), domain, null, null)); | |
}); | |
// Login Achieved. Now go to whichever page you wish, without login!! | |
this.webDriver.get("<any page user can access>"); | |
// Now Take Screenshots, Export Report etc. | |
return report; // Not defined, but assume it has necessary data | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment