Skip to content

Commit

Permalink
Attempt to improve nav to about:blank after scenarios and stop/start
Browse files Browse the repository at this point in the history
Need to make sure about:blank is loaded before continuing or it
bleeds into the next scenario and confuses things.

And it is possible to get exceptions when closing the page / browser,
so we need to catch those too...
  • Loading branch information
acoulton committed Sep 15, 2022
1 parent ccc5ac5 commit 9e84d0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ChromeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,15 @@ private function forcePageResetOrRestartDriver()
}

// If we got here then visiting about:blank failed
$this->page->close();
$this->http_client->get($this->api_url.'/json/close/'.$this->current_window);
$this->browser->close();
try {
$this->page->close();
$this->http_client->get($this->api_url.'/json/close/'.$this->current_window);
$this->browser->close();
} catch (ConnectionException $e) {
ChromeDriverDebugLogger::instance()->logAnyException('When closing page', $e);
} catch (DriverException $e) {
ChromeDriverDebugLogger::instance()->logAnyException('When closing page', $e);
}
$this->is_started = FALSE;

// And now restart
Expand Down
1 change: 1 addition & 0 deletions src/ChromePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function reset()
$this->response = null;
$this->javascript_dialog_handler = null;
$this->visit('about:blank', new \DateTimeImmutable('+5 seconds'));
$this->waitForLoad();
}

public function visit($url, ?\DateTimeImmutable $timeout = NULL)
Expand Down

0 comments on commit 9e84d0e

Please sign in to comment.