Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @return bool|Cookie|null
- * @throws Exception
- */
- function auth()
- {
- $this->driver->get(self::LOGIN_URL);
- $token_key = CaptchaService::solve_captcha('recaptcha', $this->driver);
- if (!$token_key) {
- throw new Exception('Ошибка авторизации');
- }
- $this->driver->executeScript('document.getElementById("g-recaptcha-response").style.display = ""');
- $this->driver->wait()->until(WebDriverExpectedCondition::visibilityOf($this->driver->findElement(WebDriverBy::id('g-recaptcha-response'))));
- $this->driver->findElement(WebDriverBy::id('loginform-email'))->sendKeys($this->account->email);
- $this->driver->findElement(WebDriverBy::id('loginform-password'))->sendKeys($this->account->password);
- $this->driver->findElement(WebDriverBy::id('g-recaptcha-response'))->sendKeys($token_key);
- $this->driver->executeScript('document.getElementById(\'loginform-recaptcha\').value = "' . $token_key . '";');
- $this->driver->findElement(WebDriverBy::name('signup-button'))->click();
- sleep(3);
- $PHPSESSID = $this->driver->manage()->getCookieNamed('PHPSESSID');
- $this->driver->manage()->addCookie($PHPSESSID);
- $this->account->phpsessid = $PHPSESSID->getValue();
- $this->account->save();
- return $PHPSESSID;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement