Skip to content

Commit

Permalink
Simplify exception catching code
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Nov 11, 2024
1 parent 19beb35 commit bb529ac
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,8 @@ private function applyTimeouts(): void
$this->getWebDriverSession()->timeouts($type, $param);
}
}
} catch (UnknownError $e) {
// Selenium 2.x.
throw new DriverException('Error setting timeout: ' . $e->getMessage(), 0, $e);
} catch (InvalidArgument $e) {
// Selenium 3.x.
} catch (UnknownError|InvalidArgument $e) {
// UnknownError (Selenium 2.x). InvalidArgument (Selenium 3.x).
throw new DriverException('Error setting timeout: ' . $e->getMessage(), 0, $e);
}
}
Expand Down Expand Up @@ -463,11 +460,8 @@ public function visit(string $url)
{
try {
$this->getWebDriverSession()->open($url);
} catch (Timeout $e) {
// The W3C compatible Selenium Server.
throw new DriverException('Page failed to load: ' . $e->getMessage(), 0, $e);
} catch (ScriptTimeout $e) {
// The Non-W3C compatible Selenium Server.
} catch (ScriptTimeout|Timeout $e) {
// ScriptTimeout (Selenium 2.x). Timeout (Selenium 3.x).
throw new DriverException('Page failed to load: ' . $e->getMessage(), 0, $e);
}
}
Expand Down

0 comments on commit bb529ac

Please sign in to comment.