Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. /**
  2. * @return bool|Cookie|null
  3. * @throws Exception
  4. */
  5. function auth()
  6. {
  7. $this->driver->get(self::LOGIN_URL);
  8.  
  9. $token_key = CaptchaService::solve_captcha('recaptcha', $this->driver);
  10.  
  11. if (!$token_key) {
  12. throw new Exception('Ошибка авторизации');
  13. }
  14.  
  15. $this->driver->executeScript('document.getElementById("g-recaptcha-response").style.display = ""');
  16.  
  17. $this->driver->wait()->until(WebDriverExpectedCondition::visibilityOf($this->driver->findElement(WebDriverBy::id('g-recaptcha-response'))));
  18.  
  19. $this->driver->findElement(WebDriverBy::id('loginform-email'))->sendKeys($this->account->email);
  20. $this->driver->findElement(WebDriverBy::id('loginform-password'))->sendKeys($this->account->password);
  21.  
  22. $this->driver->findElement(WebDriverBy::id('g-recaptcha-response'))->sendKeys($token_key);
  23. $this->driver->executeScript('document.getElementById(\'loginform-recaptcha\').value = "' . $token_key . '";');
  24.  
  25. $this->driver->findElement(WebDriverBy::name('signup-button'))->click();
  26.  
  27. sleep(3);
  28.  
  29. $PHPSESSID = $this->driver->manage()->getCookieNamed('PHPSESSID');
  30.  
  31. $this->driver->manage()->addCookie($PHPSESSID);
  32.  
  33. $this->account->phpsessid = $PHPSESSID->getValue();
  34. $this->account->save();
  35.  
  36. return $PHPSESSID;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement