Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing navigation methods #35

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion src/Codeception/Lib/InnerBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ public function moveBack($numberOfSteps = 1)
}
try {
$history = $this->getRunningClient()->getHistory();
for ($i = $numberOfSteps; $i > 0; $i--) {
for ($i = 0; $i < $numberOfSteps; $i++) {
$request = $history->back();
}
} catch (\LogicException $e) {
Expand Down Expand Up @@ -2131,4 +2131,56 @@ public function setMaxRedirects($maxRedirects)
{
$this->client->setMaxRedirects($maxRedirects);
}

/**
* Goes forward in the browser history.
*
* @param int $numberOfSteps (default value 1)
*/
public function moveForward($numberOfSteps = 1)
{
if (!is_int($numberOfSteps) || $numberOfSteps < 1) {
throw new \InvalidArgumentException('numberOfSteps must be positive integer');
}
try {
$history = $this->getRunningClient()->getHistory();
for ($i = 0; $i < $numberOfSteps; $i++) {
$request = $history->forward();
}
} catch (\LogicException $e) {
throw new \InvalidArgumentException(
sprintf(
'numberOfSteps is set to %d, but there are only %d steps forward in history',
$numberOfSteps,
$numberOfSteps - $i
)
);
}
$this->_loadPage(
$request->getMethod(),
$request->getUri(),
$request->getParameters(),
$request->getFiles(),
$request->getServer(),
$request->getContent()
);
}

/**
* Reloads the current browser.
*/
public function reloadPage()
{
$this->client->reload();
}

/**
* Restarts the client.
*
* It flushes history and all cookies.
*/
public function restartBrowser()
{
$this->client->restart();
}
}