Advertisement
Guest User

Untitled

a guest
May 6th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import { ScreenCap } from "../../helpers/ScreenCap"
  2. import { Casper } from "casperjs"
  3.  
  4. export class GitHubSignIn {
  5. private readonly OAUTH_AUTHORISATION_FORM = '.oauth-review-permissions form[method=post]';
  6.  
  7. constructor(private casper: Casper, private screencap: ScreenCap) { }
  8.  
  9. login(username: string, password: string): void {
  10. this.casper
  11. .then(() => {
  12. this.casper.fill('form[method=post]', {
  13. "login": username,
  14. "password": password
  15. }, true)
  16. })
  17. .then(() => {
  18. this.casper.waitFor(() => this.casper.evaluate(() => document.querySelectorAll(this.OAUTH_AUTHORISATION_FORM)))
  19. }).then(() => {
  20. this.casper.test.assertUrlMatch(
  21. /github.com\/login\/oauth\/authorize/,
  22. "GitHub application authorisation page is displayed");
  23.  
  24. this.screencap.take("gitHubAuthorisation.png");
  25. this.casper.fill(this.OAUTH_AUTHORISATION_FORM, {}, true);
  26. });
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement