Skip to content

Commit 83609f3

Browse files
committed
[py] Broaden exception handling
1 parent 1648fb9 commit 83609f3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

py/selenium/webdriver/remote/webdriver.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
1718
"""The WebDriver implementation."""
19+
1820
import base64
1921
import contextlib
2022
import copy
@@ -348,8 +350,9 @@ def start_session(self, capabilities: dict) -> None:
348350
response = self.execute(Command.NEW_SESSION, caps)["value"]
349351
self.session_id = response.get("sessionId")
350352
self.caps = response.get("capabilities")
351-
except SessionNotCreatedException:
352-
self.service.stop()
353+
except (SessionNotCreatedException, WebDriverException):
354+
if self.service is not None:
355+
self.service.stop()
353356
raise
354357

355358
def _wrap_value(self, value):

0 commit comments

Comments
 (0)